home contents changes options help

by Robin Rowe 10/23/04

img_img is a new image format library to enable programmers to read and write image file formats easily.

img_img is being developed on Windows but is designed to port easily and will be available on all major platforms.

The img_img library uses plug-ins to read/write images to a flat RGB buffer in memory. img_img includes a command-line tool that will be useful for doing image format conversions, a bit like ImageMagick's convert tool. This first release only includes a plug-in for the PPM format (8 and 16-bit), but many more formats are to follow. OpenEXR and JPEG2000 are expected next.

The fundamental img_img structure that holds images is called ImgData.

struct ImgData
{    void* raster;
     unsigned width;
     unsigned height;
     unsigned channels;
     unsigned byte_depth;
     CHANNEL_TYPE channel_type;
};
The img_img library moves images between files and this structure. The type of raster depends on the file being manipulated. img_img can handle 8-bit, 16-bit, and 32-bit rasters.

This release of img_img supports compiled-in use of the library. A future version will include img_server, a wrapper daemon that will provide rasters in shared memory and have a socket-based control protocol. Using img_server will make it possible for multiple applications to manipulate images in memory. CinePaint and Blender's Verse project intend to use img_img in the future.

Below is a simple C++ code example of using img_img. For more details see the source of main.cpp, part of the img_img command-line tool.

// initialization:
 ImgImg img_img;
 ImgPluginData plugin_data;
 memset(&plugin_data,0,sizeof(plugin_data));// Important to zero first!
// specify file to read and plug-in to use:
 plugin_data.filename = "test8.ppm";
 plugin_data.libname = "img_ppm";
// read the file into an RGB buffer:
 bool ok = img_img.Read(plugin_data);
// expose the raw RGB buffer:
 ImgData& img_data=img_img.GetImgData();
 ... do whatever you want to the flat RGB raster in memory ...
// write this 8-bit raster as a 16-bit ppm:
 plugin_data.filename = "test16.ppm";
 plugin_data.write_options = "bits=16";
 ok = img_img.Write(plugin_data);


comments:

... -- Sun, 06 Mar 2005 14:03:17 -0800 reply

... -- Sun, 10 Apr 2005 04:57:09 -0700 reply