#include <imagrgb.h>
Public Member Functions | |
| wxRGBHandler () | |
| Class constructor. | |
Private Member Functions | |
| void | ConvertShort (unsigned short *array, long length) |
| void | ConvertLong (unsigned *array, long length) |
| ImageRec * | ImageOpen (wxBufferedInputStream &buf_stream) |
| void | ImageClose (ImageRec *img) |
| void | ImageGetRow (wxBufferedInputStream &buf_stream, ImageRec *img, unsigned char *buf, int y, int z) |
Definition at line 39 of file imagrgb.h.
| wxRGBHandler::wxRGBHandler | ( | ) | [inline] |
| void wxRGBHandler::ConvertShort | ( | unsigned short * | array, | |
| long | length | |||
| ) | [private] |
Definition at line 36 of file imagrgb.cpp.
00037 { 00038 unsigned b1, b2; 00039 unsigned char *ptr; 00040 00041 ptr = (unsigned char *)array; 00042 while (length--) { 00043 b1 = *ptr++; 00044 b2 = *ptr++; 00045 *array++ = (b1 << 8) | (b2); 00046 } 00047 }
| void wxRGBHandler::ConvertLong | ( | unsigned * | array, | |
| long | length | |||
| ) | [private] |
Definition at line 49 of file imagrgb.cpp.
00050 { 00051 unsigned b1, b2, b3, b4; 00052 unsigned char *ptr; 00053 00054 ptr = (unsigned char *)array; 00055 while (length--) { 00056 b1 = *ptr++; 00057 b2 = *ptr++; 00058 b3 = *ptr++; 00059 b4 = *ptr++; 00060 *array++ = (b1 << 24) | (b2 << 16) | (b3 << 8) | (b4); 00061 } 00062 }
| ImageRec * wxRGBHandler::ImageOpen | ( | wxBufferedInputStream & | buf_stream | ) | [private] |
Definition at line 64 of file imagrgb.cpp.
00065 { 00066 union { 00067 int testWord; 00068 char testByte[4]; 00069 } endianTest; 00070 ImageRec *img; 00071 int swapFlag; 00072 int x; 00073 00074 endianTest.testWord = 1; 00075 if (endianTest.testByte[0] == 1) { 00076 swapFlag = 1; 00077 } else { 00078 swapFlag = 0; 00079 } 00080 00081 // Read the RGB header 00082 img = (ImageRec *)malloc(sizeof(ImageRec)); 00083 if (img == NULL) { 00084 LOGERROR(_("RGB: Out of memory.")); 00085 return NULL; 00086 } 00087 buf_stream.Read(img, 12); 00088 if (swapFlag) { 00089 ConvertShort(&img->imagic, 6); 00090 } 00091 img->tmp = (unsigned char *)malloc(img->xsize*256); 00092 img->tmpR = (unsigned char *)malloc(img->xsize*256); 00093 img->tmpG = (unsigned char *)malloc(img->xsize*256); 00094 img->tmpB = (unsigned char *)malloc(img->xsize*256); 00095 if (img->tmp == NULL || img->tmpR == NULL || img->tmpG == NULL || img->tmpB == NULL) { 00096 LOGERROR(_("RGB: Out of memory.")); 00097 return NULL; 00098 } 00099 00100 if ((img->type & 0xFF00) == 0x0100) { 00101 x = img->ysize * img->zsize * sizeof(unsigned); 00102 img->rowStart = (unsigned *)malloc(x); 00103 img->rowSize = (int *)malloc(x); 00104 if (img->rowStart == NULL || img->rowSize == NULL) { 00105 LOGERROR(_("RGB: Out of memory.")); 00106 return NULL; 00107 } 00108 img->rleEnd = 512 + (2 * x); 00109 buf_stream.SeekI(512); 00110 buf_stream.Read(img->rowStart, x); 00111 buf_stream.Read(img->rowSize, x); 00112 if (swapFlag) { 00113 ConvertLong(img->rowStart, x/(int)sizeof(unsigned)); 00114 ConvertLong((unsigned *)img->rowSize, x/(int)sizeof(int)); 00115 } 00116 } else { 00117 img->rowStart = NULL; 00118 img->rowSize = NULL; 00119 } 00120 return img; 00121 }
| void wxRGBHandler::ImageClose | ( | ImageRec * | img | ) | [private] |
| void wxRGBHandler::ImageGetRow | ( | wxBufferedInputStream & | buf_stream, | |
| ImageRec * | img, | |||
| unsigned char * | buf, | |||
| int | y, | |||
| int | z | |||
| ) | [private] |
Definition at line 134 of file imagrgb.cpp.
00135 { 00136 unsigned char *iPtr, *oPtr, pixel; 00137 int count; 00138 00139 if ((img->type & 0xFF00) == 0x0100) { 00140 buf_stream.SeekI((long)img->rowStart[y+z*img->ysize]); 00141 buf_stream.Read(img->tmp, (unsigned int)img->rowSize[y+z*img->ysize]); 00142 00143 iPtr = img->tmp; 00144 oPtr = buf; 00145 for (;;) { 00146 pixel = *iPtr++; 00147 count = (int)(pixel & 0x7F); 00148 if (!count) { 00149 return; 00150 } 00151 if (pixel & 0x80) { 00152 while (count--) { 00153 *oPtr++ = *iPtr++; 00154 } 00155 } else { 00156 pixel = *iPtr++; 00157 while (count--) { 00158 *oPtr++ = pixel; 00159 } 00160 } 00161 } 00162 } else { 00163 buf_stream.SeekI(512+(y*img->xsize)+(z*img->xsize*img->ysize)); 00164 buf_stream.Read(buf, img->xsize); 00165 } 00166 }
1.5.5