This graph shows which files directly or indirectly include this file:

Go to the source code of this file.
Functions | |
| void | Load256Image (const char *name, byte **pixels, byte **palette, int *width, int *height) |
| void | Load32BitImage (const char *name, unsigned **pixels, int *width, int *height) |
| void | LoadLBM (const char *filename, byte **picture, byte **palette) |
| void | LoadPCX (const char *filename, byte **picture, byte **palette, int *width, int *height) |
| void | LoadTGA (const char *filename, byte **pixels, int *width, int *height) |
| void | LoadTGABuffer (byte *buffer, byte **pic, int *width, int *height) |
| void | Save256Image (const char *name, byte *pixels, byte *palette, int width, int height) |
| void | WriteLBMfile (const char *filename, byte *data, int width, int height, byte *palette) |
| void | WritePCXfile (const char *filename, byte *data, int width, int height, byte *palette) |
| void | WriteTGA (const char *filename, byte *data, int width, int height) |
|
||||||||||||||||||||||||
|
Definition at line 774 of file imagelib.c. References bmhd, byte, Error(), ExtractFileExtension(), bmhd_t::h, height, LoadBMP(), LoadLBM(), LoadPCX(), name, pixels, Q_stricmp(), bmhd_t::w, and width. 00776 {
00777 char ext[128];
00778
00779 ExtractFileExtension (name, ext);
00780 if (!Q_stricmp (ext, "lbm"))
00781 {
00782 LoadLBM (name, pixels, palette);
00783 if (width)
00784 *width = bmhd.w;
00785 if (height)
00786 *height = bmhd.h;
00787 }
00788 else if (!Q_stricmp (ext, "pcx"))
00789 {
00790 LoadPCX (name, pixels, palette, width, height);
00791 }
00792 else if (!Q_stricmp (ext, "bmp"))
00793 {
00794 LoadBMP (name, pixels, palette, width, height);
00795 }
00796 else
00797 Error ("%s doesn't have a known image extension", name);
00798 }
|
Here is the call graph for this function:

|
||||||||||||||||||||
|
Definition at line 1133 of file imagelib.c. References byte, ExtractFileExtension(), height, i, Load256Image(), LoadTGA(), malloc(), name, pixels, Q_stricmp(), v, and width. Referenced by LoadAlphaMap(). 01134 {
01135 char ext[128];
01136 byte *palette;
01137 byte *pixels8;
01138 byte *pixels32;
01139 int size;
01140 int i;
01141 int v;
01142
01143 ExtractFileExtension (name, ext);
01144 if (!Q_stricmp (ext, "tga")) {
01145 LoadTGA (name, (byte **)pixels, width, height);
01146 } else {
01147 Load256Image (name, &pixels8, &palette, width, height);
01148 if (!pixels) {
01149 return;
01150 }
01151 size = *width * *height;
01152 pixels32 = malloc(size * 4);
01153 *pixels = (unsigned *)pixels32;
01154 for (i = 0 ; i < size ; i++) {
01155 v = pixels8[i];
01156 pixels32[i*4 + 0] = palette[ v * 3 + 0 ];
01157 pixels32[i*4 + 1] = palette[ v * 3 + 1 ];
01158 pixels32[i*4 + 2] = palette[ v * 3 + 2 ];
01159 pixels32[i*4 + 3] = 0xff;
01160 }
01161 }
01162 }
|
Here is the call graph for this function:

|
||||||||||||||||
|
Definition at line 168 of file imagelib.c. References Align(), BigLong(), BigShort(), bmhd, BMHDID, BODYID, byte, CMAPID, bmhd_t::compression, Error(), FORMID, free(), bmhd_t::h, ILBMID, LBMRLEDecompress(), LittleLong(), LoadFile(), malloc(), memcpy(), memset(), bmhd_t::pageHeight, bmhd_t::pageWidth, bmhd_t::w, bmhd_t::x, y, and bmhd_t::y. 00169 {
00170 byte *LBMbuffer, *picbuffer, *cmapbuffer;
00171 int y;
00172 byte *LBM_P, *LBMEND_P;
00173 byte *pic_p;
00174 byte *body_p;
00175
00176 int formtype,formlength;
00177 int chunktype,chunklength;
00178
00179 // qiet compiler warnings
00180 picbuffer = NULL;
00181 cmapbuffer = NULL;
00182
00183 //
00184 // load the LBM
00185 //
00186 LoadFile (filename, (void **)&LBMbuffer);
00187
00188 //
00189 // parse the LBM header
00190 //
00191 LBM_P = LBMbuffer;
00192 if ( *(int *)LBMbuffer != LittleLong(FORMID) )
00193 Error ("No FORM ID at start of file!\n");
00194
00195 LBM_P += 4;
00196 formlength = BigLong( *(int *)LBM_P );
00197 LBM_P += 4;
00198 LBMEND_P = LBM_P + Align(formlength);
00199
00200 formtype = LittleLong(*(int *)LBM_P);
00201
00202 if (formtype != ILBMID && formtype != PBMID)
00203 Error ("Unrecognized form type: %c%c%c%c\n", formtype&0xff
00204 ,(formtype>>8)&0xff,(formtype>>16)&0xff,(formtype>>24)&0xff);
00205
00206 LBM_P += 4;
00207
00208 //
00209 // parse chunks
00210 //
00211
00212 while (LBM_P < LBMEND_P)
00213 {
00214 chunktype = LBM_P[0] + (LBM_P[1]<<8) + (LBM_P[2]<<16) + (LBM_P[3]<<24);
00215 LBM_P += 4;
00216 chunklength = LBM_P[3] + (LBM_P[2]<<8) + (LBM_P[1]<<16) + (LBM_P[0]<<24);
00217 LBM_P += 4;
00218
00219 switch ( chunktype )
00220 {
00221 case BMHDID:
00222 memcpy (&bmhd,LBM_P,sizeof(bmhd));
00223 bmhd.w = BigShort(bmhd.w);
00224 bmhd.h = BigShort(bmhd.h);
00225 bmhd.x = BigShort(bmhd.x);
00226 bmhd.y = BigShort(bmhd.y);
00227 bmhd.pageWidth = BigShort(bmhd.pageWidth);
00228 bmhd.pageHeight = BigShort(bmhd.pageHeight);
00229 break;
00230
00231 case CMAPID:
00232 cmapbuffer = malloc (768);
00233 memset (cmapbuffer, 0, 768);
00234 memcpy (cmapbuffer, LBM_P, chunklength);
00235 break;
00236
00237 case BODYID:
00238 body_p = LBM_P;
00239
00240 pic_p = picbuffer = malloc (bmhd.w*bmhd.h);
00241 if (formtype == PBMID)
00242 {
00243 //
00244 // unpack PBM
00245 //
00246 for (y=0 ; y<bmhd.h ; y++, pic_p += bmhd.w)
00247 {
00248 if (bmhd.compression == cm_rle1)
00249 body_p = LBMRLEDecompress ((byte *)body_p
00250 , pic_p , bmhd.w);
00251 else if (bmhd.compression == cm_none)
00252 {
00253 memcpy (pic_p,body_p,bmhd.w);
00254 body_p += Align(bmhd.w);
00255 }
00256 }
00257
00258 }
00259 else
00260 {
00261 //
00262 // unpack ILBM
00263 //
00264 Error ("%s is an interlaced LBM, not packed", filename);
00265 }
00266 break;
00267 }
00268
00269 LBM_P += Align(chunklength);
00270 }
00271
00272 free (LBMbuffer);
00273
00274 *picture = picbuffer;
00275
00276 if (palette)
00277 *palette = cmapbuffer;
00278 }
|
Here is the call graph for this function:

|
||||||||||||||||||||||||
|
Definition at line 433 of file imagelib.c. References pcx_t::bits_per_pixel, byte, pcx_t::bytes_per_line, pcx_t::data, pcx_t::encoding, Error(), free(), height, pcx_t::hres, LittleShort(), LoadFile(), malloc(), pcx_t::manufacturer, memcpy(), pcx_t::palette_type, pcx_t::version, pcx_t::vres, width, x, pcx_t::xmax, pcx_t::xmin, y, pcx_t::ymax, and pcx_t::ymin. 00434 {
00435 byte *raw;
00436 pcx_t *pcx;
00437 int x, y;
00438 int len;
00439 int dataByte, runLength;
00440 byte *out, *pix;
00441
00442 //
00443 // load the file
00444 //
00445 len = LoadFile (filename, (void **)&raw);
00446
00447 //
00448 // parse the PCX file
00449 //
00450 pcx = (pcx_t *)raw;
00451 raw = &pcx->data;
00452
00453 pcx->xmin = LittleShort(pcx->xmin);
00454 pcx->ymin = LittleShort(pcx->ymin);
00455 pcx->xmax = LittleShort(pcx->xmax);
00456 pcx->ymax = LittleShort(pcx->ymax);
00457 pcx->hres = LittleShort(pcx->hres);
00458 pcx->vres = LittleShort(pcx->vres);
00459 pcx->bytes_per_line = LittleShort(pcx->bytes_per_line);
00460 pcx->palette_type = LittleShort(pcx->palette_type);
00461
00462 if (pcx->manufacturer != 0x0a
00463 || pcx->version != 5
00464 || pcx->encoding != 1
00465 || pcx->bits_per_pixel != 8
00466 || pcx->xmax >= 640
00467 || pcx->ymax >= 480)
00468 Error ("Bad pcx file %s", filename);
00469
00470 if (palette)
00471 {
00472 *palette = malloc(768);
00473 memcpy (*palette, (byte *)pcx + len - 768, 768);
00474 }
00475
00476 if (width)
00477 *width = pcx->xmax+1;
00478 if (height)
00479 *height = pcx->ymax+1;
00480
00481 if (!pic)
00482 return;
00483
00484 out = malloc ( (pcx->ymax+1) * (pcx->xmax+1) );
00485 if (!out)
00486 Error ("Skin_Cache: couldn't allocate");
00487
00488 *pic = out;
00489
00490 pix = out;
00491
00492 for (y=0 ; y<=pcx->ymax ; y++, pix += pcx->xmax+1)
00493 {
00494 for (x=0 ; x<=pcx->xmax ; )
00495 {
00496 dataByte = *raw++;
00497
00498 if((dataByte & 0xC0) == 0xC0)
00499 {
00500 runLength = dataByte & 0x3F;
00501 dataByte = *raw++;
00502 }
00503 else
00504 runLength = 1;
00505
00506 // FIXME: this shouldn't happen, but it does. Are we decoding the file wrong?
00507 // Truncate runLength so we don't overrun the end of the buffer
00508 if ( ( y == pcx->ymax ) && ( x + runLength > pcx->xmax + 1 ) ) {
00509 runLength = pcx->xmax - x + 1;
00510 }
00511
00512 while(runLength-- > 0)
00513 pix[x++] = dataByte;
00514 }
00515
00516 }
00517
00518 if ( raw - (byte *)pcx > len)
00519 Error ("PCX file %s was malformed", filename);
00520
00521 free (pcx);
00522 }
|
Here is the call graph for this function:

|
||||||||||||||||||||
|
Definition at line 1063 of file imagelib.c. References buffer, byte, Error(), height, LoadFile(), LoadTGABuffer(), name, pixels, and width. 01064 {
01065 byte *buffer;
01066 int nLen;
01067 //
01068 // load the file
01069 //
01070 nLen = LoadFile ( ( char * ) name, (void **)&buffer);
01071 if (nLen == -1)
01072 {
01073 Error ("Couldn't read %s", name);
01074 }
01075
01076 LoadTGABuffer(buffer, pixels, width, height);
01077
01078 }
|
Here is the call graph for this function:

|
||||||||||||||||||||
|
Definition at line 850 of file imagelib.c. References _TargaHeader::attributes, blue, byte, _TargaHeader::colormap_index, _TargaHeader::colormap_length, _TargaHeader::colormap_size, _TargaHeader::colormap_type, Error(), green, height, _TargaHeader::height, _TargaHeader::id_length, _TargaHeader::image_type, j, LittleShort(), malloc(), _TargaHeader::pixel_size, rows, TargaHeader, width, _TargaHeader::width, _TargaHeader::x_origin, and _TargaHeader::y_origin. Referenced by LoadShaderImage(), and LoadTGA(). 00851 {
00852 int columns, rows, numPixels;
00853 byte *pixbuf;
00854 int row, column;
00855 byte *buf_p;
00856 TargaHeader targa_header;
00857 byte *targa_rgba;
00858
00859 *pic = NULL;
00860
00861 buf_p = buffer;
00862
00863 targa_header.id_length = *buf_p++;
00864 targa_header.colormap_type = *buf_p++;
00865 targa_header.image_type = *buf_p++;
00866
00867 targa_header.colormap_index = LittleShort ( *(short *)buf_p );
00868 buf_p += 2;
00869 targa_header.colormap_length = LittleShort ( *(short *)buf_p );
00870 buf_p += 2;
00871 targa_header.colormap_size = *buf_p++;
00872 targa_header.x_origin = LittleShort ( *(short *)buf_p );
00873 buf_p += 2;
00874 targa_header.y_origin = LittleShort ( *(short *)buf_p );
00875 buf_p += 2;
00876 targa_header.width = LittleShort ( *(short *)buf_p );
00877 buf_p += 2;
00878 targa_header.height = LittleShort ( *(short *)buf_p );
00879 buf_p += 2;
00880 targa_header.pixel_size = *buf_p++;
00881 targa_header.attributes = *buf_p++;
00882
00883 if (targa_header.image_type!=2
00884 && targa_header.image_type!=10
00885 && targa_header.image_type != 3 )
00886 {
00887 Error("LoadTGA: Only type 2 (RGB), 3 (gray), and 10 (RGB) TGA images supported\n");
00888 }
00889
00890 if ( targa_header.colormap_type != 0 )
00891 {
00892 Error("LoadTGA: colormaps not supported\n" );
00893 }
00894
00895 if ( ( targa_header.pixel_size != 32 && targa_header.pixel_size != 24 ) && targa_header.image_type != 3 )
00896 {
00897 Error("LoadTGA: Only 32 or 24 bit images supported (no colormaps)\n");
00898 }
00899
00900 columns = targa_header.width;
00901 rows = targa_header.height;
00902 numPixels = columns * rows;
00903
00904 if (width)
00905 *width = columns;
00906 if (height)
00907 *height = rows;
00908
00909 targa_rgba = malloc (numPixels*4);
00910 *pic = targa_rgba;
00911
00912 if (targa_header.id_length != 0)
00913 buf_p += targa_header.id_length; // skip TARGA image comment
00914
00915 if ( targa_header.image_type==2 || targa_header.image_type == 3 )
00916 {
00917 // Uncompressed RGB or gray scale image
00918 for(row=rows-1; row>=0; row--)
00919 {
00920 pixbuf = targa_rgba + row*columns*4;
00921 for(column=0; column<columns; column++)
00922 {
00923 unsigned char red,green,blue,alphabyte;
00924 switch (targa_header.pixel_size)
00925 {
00926
00927 case 8:
00928 blue = *buf_p++;
00929 green = blue;
00930 red = blue;
00931 *pixbuf++ = red;
00932 *pixbuf++ = green;
00933 *pixbuf++ = blue;
00934 *pixbuf++ = 255;
00935 break;
00936
00937 case 24:
00938 blue = *buf_p++;
00939 green = *buf_p++;
00940 red = *buf_p++;
00941 *pixbuf++ = red;
00942 *pixbuf++ = green;
00943 *pixbuf++ = blue;
00944 *pixbuf++ = 255;
00945 break;
00946 case 32:
00947 blue = *buf_p++;
00948 green = *buf_p++;
00949 red = *buf_p++;
00950 alphabyte = *buf_p++;
00951 *pixbuf++ = red;
00952 *pixbuf++ = green;
00953 *pixbuf++ = blue;
00954 *pixbuf++ = alphabyte;
00955 break;
00956 default:
00957 //Error("LoadTGA: illegal pixel_size '%d' in file '%s'\n", targa_header.pixel_size, name );
00958 break;
00959 }
00960 }
00961 }
00962 }
00963 else if (targa_header.image_type==10) { // Runlength encoded RGB images
00964 unsigned char red,green,blue,alphabyte,packetHeader,packetSize,j;
00965
00966 red = 0;
00967 green = 0;
00968 blue = 0;
00969 alphabyte = 0xff;
00970
00971 for(row=rows-1; row>=0; row--) {
00972 pixbuf = targa_rgba + row*columns*4;
00973 for(column=0; column<columns; ) {
00974 packetHeader= *buf_p++;
00975 packetSize = 1 + (packetHeader & 0x7f);
00976 if (packetHeader & 0x80) { // run-length packet
00977 switch (targa_header.pixel_size) {
00978 case 24:
00979 blue = *buf_p++;
00980 green = *buf_p++;
00981 red = *buf_p++;
00982 alphabyte = 255;
00983 break;
00984 case 32:
00985 blue = *buf_p++;
00986 green = *buf_p++;
00987 red = *buf_p++;
00988 alphabyte = *buf_p++;
00989 break;
00990 default:
00991 //Error("LoadTGA: illegal pixel_size '%d' in file '%s'\n", targa_header.pixel_size, name );
00992 break;
00993 }
00994
00995 for(j=0;j<packetSize;j++) {
00996 *pixbuf++=red;
00997 *pixbuf++=green;
00998 *pixbuf++=blue;
00999 *pixbuf++=alphabyte;
01000 column++;
01001 if (column==columns) { // run spans across rows
01002 column=0;
01003 if (row>0)
01004 row--;
01005 else
01006 goto breakOut;
01007 pixbuf = targa_rgba + row*columns*4;
01008 }
01009 }
01010 }
01011 else { // non run-length packet
01012 for(j=0;j<packetSize;j++) {
01013 switch (targa_header.pixel_size) {
01014 case 24:
01015 blue = *buf_p++;
01016 green = *buf_p++;
01017 red = *buf_p++;
01018 *pixbuf++ = red;
01019 *pixbuf++ = green;
01020 *pixbuf++ = blue;
01021 *pixbuf++ = 255;
01022 break;
01023 case 32:
01024 blue = *buf_p++;
01025 green = *buf_p++;
01026 red = *buf_p++;
01027 alphabyte = *buf_p++;
01028 *pixbuf++ = red;
01029 *pixbuf++ = green;
01030 *pixbuf++ = blue;
01031 *pixbuf++ = alphabyte;
01032 break;
01033 default:
01034 //Sys_Printf("LoadTGA: illegal pixel_size '%d' in file '%s'\n", targa_header.pixel_size, name );
01035 break;
01036 }
01037 column++;
01038 if (column==columns) { // pixel packet run spans across rows
01039 column=0;
01040 if (row>0)
01041 row--;
01042 else
01043 goto breakOut;
01044 pixbuf = targa_rgba + row*columns*4;
01045 }
01046 }
01047 }
01048 }
01049 breakOut:;
01050 }
01051 }
01052
01053 //free(buffer);
01054 }
|
Here is the call graph for this function:

|
||||||||||||||||||||||||
|
Definition at line 808 of file imagelib.c. References byte, Error(), ExtractFileExtension(), height, name, pixels, Q_stricmp(), width, WriteLBMfile(), and WritePCXfile(). 00810 {
00811 char ext[128];
00812
00813 ExtractFileExtension (name, ext);
00814 if (!Q_stricmp (ext, "lbm"))
00815 {
00816 WriteLBMfile (name, pixels, width, height, palette);
00817 }
00818 else if (!Q_stricmp (ext, "pcx"))
00819 {
00820 WritePCXfile (name, pixels, width, height, palette);
00821 }
00822 else
00823 Error ("%s doesn't have a known image extension", name);
00824 }
|
Here is the call graph for this function:

|
||||||||||||||||||||||||
|
Definition at line 294 of file imagelib.c. References BigLong(), BigShort(), byte, data, free(), bmhd_t::h, height, length(), malloc(), memcpy(), memset(), bmhd_t::nPlanes, bmhd_t::pageHeight, bmhd_t::pageWidth, SaveFile(), bmhd_t::w, width, bmhd_t::xAspect, and bmhd_t::yAspect. 00296 {
00297 byte *lbm, *lbmptr;
00298 int *formlength, *bmhdlength, *cmaplength, *bodylength;
00299 int length;
00300 bmhd_t basebmhd;
00301
00302 lbm = lbmptr = malloc (width*height+1000);
00303
00304 //
00305 // start FORM
00306 //
00307 *lbmptr++ = 'F';
00308 *lbmptr++ = 'O';
00309 *lbmptr++ = 'R';
00310 *lbmptr++ = 'M';
00311
00312 formlength = (int*)lbmptr;
00313 lbmptr+=4; // leave space for length
00314
00315 *lbmptr++ = 'P';
00316 *lbmptr++ = 'B';
00317 *lbmptr++ = 'M';
00318 *lbmptr++ = ' ';
00319
00320 //
00321 // write BMHD
00322 //
00323 *lbmptr++ = 'B';
00324 *lbmptr++ = 'M';
00325 *lbmptr++ = 'H';
00326 *lbmptr++ = 'D';
00327
00328 bmhdlength = (int *)lbmptr;
00329 lbmptr+=4; // leave space for length
00330
00331 memset (&basebmhd,0,sizeof(basebmhd));
00332 basebmhd.w = BigShort((short)width);
00333 basebmhd.h = BigShort((short)height);
00334 basebmhd.nPlanes = BigShort(8);
00335 basebmhd.xAspect = BigShort(5);
00336 basebmhd.yAspect = BigShort(6);
00337 basebmhd.pageWidth = BigShort((short)width);
00338 basebmhd.pageHeight = BigShort((short)height);
00339
00340 memcpy (lbmptr,&basebmhd,sizeof(basebmhd));
00341 lbmptr += sizeof(basebmhd);
00342
00343 length = lbmptr-(byte *)bmhdlength-4;
00344 *bmhdlength = BigLong(length);
00345 if (length&1)
00346 *lbmptr++ = 0; // pad chunk to even offset
00347
00348 //
00349 // write CMAP
00350 //
00351 *lbmptr++ = 'C';
00352 *lbmptr++ = 'M';
00353 *lbmptr++ = 'A';
00354 *lbmptr++ = 'P';
00355
00356 cmaplength = (int *)lbmptr;
00357 lbmptr+=4; // leave space for length
00358
00359 memcpy (lbmptr,palette,768);
00360 lbmptr += 768;
00361
00362 length = lbmptr-(byte *)cmaplength-4;
00363 *cmaplength = BigLong(length);
00364 if (length&1)
00365 *lbmptr++ = 0; // pad chunk to even offset
00366
00367 //
00368 // write BODY
00369 //
00370 *lbmptr++ = 'B';
00371 *lbmptr++ = 'O';
00372 *lbmptr++ = 'D';
00373 *lbmptr++ = 'Y';
00374
00375 bodylength = (int *)lbmptr;
00376 lbmptr+=4; // leave space for length
00377
00378 memcpy (lbmptr,data,width*height);
00379 lbmptr += width*height;
00380
00381 length = lbmptr-(byte *)bodylength-4;
00382 *bodylength = BigLong(length);
00383 if (length&1)
00384 *lbmptr++ = 0; // pad chunk to even offset
00385
00386 //
00387 // done
00388 //
00389 length = lbmptr-(byte *)formlength-4;
00390 *formlength = BigLong(length);
00391 if (length&1)
00392 *lbmptr++ = 0; // pad chunk to even offset
00393
00394 //
00395 // write output file
00396 //
00397 SaveFile (filename, lbm, lbmptr-lbm);
00398 free (lbm);
00399 }
|
Here is the call graph for this function:

|
||||||||||||||||||||||||
|
Definition at line 529 of file imagelib.c. References pcx_t::bits_per_pixel, byte, pcx_t::bytes_per_line, pcx_t::color_planes, data, pcx_t::data, pcx_t::encoding, free(), height, pcx_t::hres, i, j, length(), LittleShort(), malloc(), pcx_t::manufacturer, memset(), pcx_t::palette_type, SaveFile(), pcx_t::version, pcx_t::vres, width, pcx_t::xmax, pcx_t::xmin, pcx_t::ymax, and pcx_t::ymin. 00531 {
00532 int i, j, length;
00533 pcx_t *pcx;
00534 byte *pack;
00535
00536 pcx = malloc (width*height*2+1000);
00537 memset (pcx, 0, sizeof(*pcx));
00538
00539 pcx->manufacturer = 0x0a; // PCX id
00540 pcx->version = 5; // 256 color
00541 pcx->encoding = 1; // uncompressed
00542 pcx->bits_per_pixel = 8; // 256 color
00543 pcx->xmin = 0;
00544 pcx->ymin = 0;
00545 pcx->xmax = LittleShort((short)(width-1));
00546 pcx->ymax = LittleShort((short)(height-1));
00547 pcx->hres = LittleShort((short)width);
00548 pcx->vres = LittleShort((short)height);
00549 pcx->color_planes = 1; // chunky image
00550 pcx->bytes_per_line = LittleShort((short)width);
00551 pcx->palette_type = LittleShort(1); // not a grey scale
00552
00553 // pack the image
00554 pack = &pcx->data;
00555
00556 for (i=0 ; i<height ; i++)
00557 {
00558 for (j=0 ; j<width ; j++)
00559 {
00560 if ( (*data & 0xc0) != 0xc0)
00561 *pack++ = *data++;
00562 else
00563 {
00564 *pack++ = 0xc1;
00565 *pack++ = *data++;
00566 }
00567 }
00568 }
00569
00570 // write the palette
00571 *pack++ = 0x0c; // palette ID byte
00572 for (i=0 ; i<768 ; i++)
00573 *pack++ = *palette++;
00574
00575 // write output file
00576 length = pack - (byte *)pcx;
00577 SaveFile (filename, pcx, length);
00578
00579 free (pcx);
00580 }
|
Here is the call graph for this function:

|
||||||||||||||||||||
|
Definition at line 1086 of file imagelib.c. References buffer, byte, c, data, f, fclose(), fopen(), free(), fwrite(), height, i, malloc(), memset(), and width. Referenced by RE_RegisterFont(). 01086 {
01087 byte *buffer;
01088 int i;
01089 int c;
01090 FILE *f;
01091
01092 buffer = malloc(width*height*4 + 18);
01093 memset (buffer, 0, 18);
01094 buffer[2] = 2; // uncompressed type
01095 buffer[12] = width&255;
01096 buffer[13] = width>>8;
01097 buffer[14] = height&255;
01098 buffer[15] = height>>8;
01099 buffer[16] = 32; // pixel size
01100
01101 // swap rgb to bgr
01102 c = 18 + width * height * 4;
01103 for (i=18 ; i<c ; i+=4)
01104 {
01105 buffer[i] = data[i-18+2]; // blue
01106 buffer[i+1] = data[i-18+1]; // green
01107 buffer[i+2] = data[i-18+0]; // red
01108 buffer[i+3] = data[i-18+3]; // alpha
01109 }
01110
01111 f = fopen (filename, "wb");
01112 fwrite (buffer, 1, c, f);
01113 fclose (f);
01114
01115 free (buffer);
01116 }
|
Here is the call graph for this function:

1.3.9.1