int main ( int argc, char* argv[] ) { JString fileName; JBoolean printInfo; int transparentColor; LaceOption interlace; JBoolean padColormap; JBoolean blend; JFloat alpha; JRGB alphaColor; JString blendOutput; ParseOptions(argc, argv, &fileName, &printInfo, &transparentColor, &interlace, &padColormap, &blend, &alpha, &alphaColor, &blendOutput); JBoolean changed = kJFalse; gdImagePtr image = ReadGIF(fileName); if (printInfo) { PrintGIFInfo(image); } if (SetTransparentColor(image, transparentColor)) { changed = kJTrue; } if (SetInterlace(image, interlace)) { changed = kJTrue; } if (padColormap && PadColormap(image)) { changed = kJTrue; } if (blend) { Blend(image, alpha, alphaColor, blendOutput); } if (changed) { WriteGIF(image, fileName); } gdImageDestroy(image); return 0; }
static DFBResult Construct( IDirectFBImageProvider *thiz, ... ) { IDirectFBDataBuffer *buffer; CoreDFB *core; va_list tag; DIRECT_ALLOCATE_INTERFACE_DATA(thiz, IDirectFBImageProvider_GIF) va_start( tag, thiz ); buffer = va_arg( tag, IDirectFBDataBuffer * ); core = va_arg( tag, CoreDFB * ); va_end( tag ); data->base.ref = 1; data->base.buffer = buffer; data->base.core = core; buffer->AddRef( buffer ); data->GrayScale = -1; data->transparent = -1; data->delayTime = -1; data->image = ReadGIF( data, 1, &data->image_width, &data->image_height, &data->image_transparency, &data->image_colorkey, true, false ); buffer->Release( buffer ); data->base.buffer = NULL; if (!data->image || (data->image_height == 0) || (data->image_width == 0) ) { DIRECT_DEALLOCATE_INTERFACE( thiz ); return DFB_FAILURE; } data->base.Destruct = IDirectFBImageProvider_GIF_Destruct; thiz->RenderTo = IDirectFBImageProvider_GIF_RenderTo; thiz->GetImageDescription = IDirectFBImageProvider_GIF_GetImageDescription; thiz->GetSurfaceDescription = IDirectFBImageProvider_GIF_GetSurfaceDescription; return DFB_OK; }
LDraw::Bitmap* BitmapLoader::Load(IO::ISequentialByteStream* stream) { int n; for (n = 0; n < 5; n++) { int ret = -1; switch (n) { case 0: { ret = ReadJPEG(this, stream); } break; case 1: { ret = ReadGIF(this, stream); } break; case 2: { ret = ReadPNG(this, stream); } break; case 3: { ret = ReadBMP(this, stream); } break; case 4: { ret = ReadTGA(this, stream); } break; } if (ret == 0) break; stream->Seek(0, System::IO::STREAM_SEEK_SET); } return m_bitmap; }
/*--------------------------------------------------------------------------- This routine is adapted from Mosaic-2.0. We only read GIF files, for now. Written by HRL. Modified by COMET. ----------------------------------------------------------------------------*/ unsigned char *ReadBitmap(char *datafile,int *w,int *h,XColor *colrs,int *bg) { unsigned char *bit_data; FILE *fp; int verbose; verbose = GetVerboseLevel(); if( verbose > VERBOSE_0 ) printf ( "ReadBitmap\n" ); *bg = -1; /* Obviously this isn't going to work. */ fp = fopen(datafile, "r"); if (fp != NULL) { bit_data = ReadGIF(fp, w, h, colrs); if (bit_data != NULL) { if (fp != stdin) fclose(fp); return(bit_data); } rewind(fp); /* bit_data = ReadXbmBitmap(fp, datafile, w, h, colrs); if (bit_data != NULL) { if (fp != stdin) fclose(fp); return(bit_data); } rewind(fp); bit_data = ReadXpm3Pixmap(fp, datafile, w, h, colrs, bg); if (bit_data != NULL) { if (fp != stdin) fclose(fp); return(bit_data); }*/ } if (fp != stdin) fclose(fp); return((unsigned char *)NULL); }