|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
|
Announcements
Chapters
Services
Feature Zones
|
IntroductionThis article provides information on the decoder for Sun Raster files. I had been using a free image library for quiet some time. A few days back, I wanted to support the Sun Raster file format (.ras). Since the library I am currently using doesn't support this format, I started looking for a decoder. I found that the FreeImage Imaging Library supports this format. So I used this library as a reference to write a standalone decoder. The RAS File FormatThe RAS format is described here. The RAS HeaderThe RAS header is as follows: struct RASHEADER { DWORD magic; // Magic number DWORD width; // Image width in pixels DWORD height; // Image height in pixels DWORD depth; // Depth (1, 8, 24 or 32 bits) of each pixel DWORD length; // Image length (in bytes) DWORD type; // Format of file DWORD maptype; // Type of colormap DWORD maplength; // Length of colormap (in bytes) } RASHEADER; Note the following: #define RAS_MAGIC 0x59A66A95 // Magic number for Sun rasterfiles A check for the above number should be done after reading the header information to verify if it's a SUN Raster file. The RAS decoder consists of a class
The A simple usage of the class would be as follows: CLibRAS Decoder; BMP *dib = Decoder.LoadRAS(fopen("C:\\lady256.ras","rb")); ::StretchDIBits(AfxGetMainWnd()->GetDC()->m_hDC, 10, // Destination x 10, // Destination y Decoder.GetWidth(dib), // Destination width Decoder.GetHeight(dib), // Destination height 0, // Source x 0, // Source y Decoder.GetWidth(dib), // Source width Decoder.GetHeight(dib), // Source height Decoder.GetBits(dib), // Pointer to bits Decoder.GetInfo(dib), // BITMAPINFO DIB_RGB_COLORS, // Options SRCCOPY); // Raster operator code Would appreciate if you post the results after usage.
|
||||||||||||||||||||||