Exemplo n.º 1
0
int LoadPic(char *filename, Pixmap *pm, XpmAttributes *xa)
{
  Pixmap shape;

#ifdef HAVE_LIBJPEG
  xa->valuemask=XpmColormap|XpmReturnAllocPixels;
  xa->colormap=TheScreen.colormap;
  if(None == (*pm = LoadJpeg(disp, TheScreen.root, filename, xa))) {
#endif
    xa->valuemask=XpmColormap|XpmReturnAllocPixels;
    xa->colormap=TheScreen.colormap;
    if(XpmReadFileToPixmap(disp,TheScreen.root, filename, pm, &shape, xa)){
      *pm = None;
      return(0);
    }
    if(shape != None) XFreePixmap(disp,shape);
#ifdef HAVE_LIBJPEG
  }
#endif
  return(1);
}
Exemplo n.º 2
0
/**
 * Constructor for the GuiImageData class.
 */
GuiImageData::GuiImageData(const u8 * img, int imgSize)
{
	data = NULL;
    //AnimGif = NULL;
	width = 0;
	height = 0;
	format = GX_TF_RGBA8;

	if(img)
	{
		if (imgSize < 8)
		{
			return;
		}
		if (img[0] == 0xFF && img[1] == 0xD8)
		{
		    // IMAGE_JPEG
			LoadJpeg(img, imgSize);
		}
		else if (img[0] == 0x49 && img[1] == 0x49)
		{
		    // IMAGE_TIFF_PC
            LoadTIFF(img, imgSize);
		}
		else if (img[0] == 0x4D && img[1] == 0x4D)
		{
		    // IMAGE_TIFF_MAC
            LoadTIFF(img, imgSize);
		}
		else if (img[0] == 'B' && img[1] == 'M')
		{
		    // IMAGE_BMP
			LoadBMP(img, imgSize);
		}
		/*else if (img[0] == 'G' && img[1] == 'I' && img[2] == 'F')
		{
		    // IMAGE_GIF
			LoadGIF(img, imgSize);
		}*/
		else if (img[0] == 0x89 && img[1] == 'P' && img[2] == 'N' && img[3] == 'G')
		{
		    // IMAGE_PNG
			LoadPNG(img, imgSize);
		}
		else if ((img[0] == 0xFF && img[1] == 0xFF) || (img[0] == 0xFF && img[1] == 0xFE))
		{
		    // IMAGE_GD
			LoadGD(img, imgSize);
		}
		else if (img[0] == 0x67 && img[1] == 0x64 && img[2] == 0x32 && img[3] == 0x00)
		{
		    // IMAGE_GD2
			LoadGD2(img, imgSize);
		}
		else if (img[0] == 0x00 && img[1] == 0x20 && img[2] == 0xAF && img[3] == 0x30)
		{
		    // IMAGE_TPL
			LoadTPL(img, imgSize);
		}
		//!This must be last since it can also intefere with outher formats
		else if(img[0] == 0x00)
		{
		    // Try loading TGA image
			LoadTGA(img, imgSize);
		}
	}
}