Beispiel #1
0
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                                                             %
%                                                                             %
%                                                                             %
%   W r i t e C L I P I m a g e                                               %
%                                                                             %
%                                                                             %
%                                                                             %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%  WriteCLIPImage() writes an image of clip bytes to a file.  It consists of
%  data from the clip mask of the image.
%
%  The format of the WriteCLIPImage method is:
%
%      MagickBooleanType WriteCLIPImage(const ImageInfo *image_info,
%        Image *image)
%
%  A description of each parameter follows.
%
%    o image_info: The image info.
%
%    o image:  The image.
%
*/
static MagickBooleanType WriteCLIPImage(const ImageInfo *image_info,
  Image *image)
{
  Image
    *clip_image;

  ImageInfo
    *write_info;

  MagickBooleanType
    status;

  if (image->clip_mask == (Image *) NULL)
    (void) ClipImage(image);
  if (image->clip_mask == (Image *) NULL)
    ThrowWriterException(CoderError,"ImageDoesNotHaveAClipMask");
  clip_image=CloneImage(image->clip_mask,0,0,MagickTrue,&image->exception);
  if (clip_image == (Image *) NULL)
    return(MagickFalse);
  (void) SetImageType(clip_image,TrueColorType);
  (void) CopyMagickString(clip_image->filename,image->filename,MaxTextExtent);
  write_info=CloneImageInfo(image_info);
  (void) SetImageInfo(write_info,MagickTrue,&image->exception);
  if (LocaleCompare(write_info->magick,"CLIP") == 0)
    (void) FormatMagickString(clip_image->filename,MaxTextExtent,"miff:%s",
      write_info->filename);
  status=WriteImage(write_info,clip_image);
  clip_image=DestroyImage(clip_image);
  write_info=DestroyImageInfo(write_info);
  return(status);
}
Beispiel #2
0
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                                                             %
%                                                                             %
%                                                                             %
%   W r i t e C L I P I m a g e                                               %
%                                                                             %
%                                                                             %
%                                                                             %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%  WriteCLIPImage() writes an image of clip bytes to a file.  It consists of
%  data from the clip mask of the image.
%
%  The format of the WriteCLIPImage method is:
%
%      MagickBooleanType WriteCLIPImage(const ImageInfo *image_info,
%        Image *image,ExceptionInfo *exception)
%
%  A description of each parameter follows.
%
%    o image_info: the image info.
%
%    o image:  The image.
%
%    o exception: return any errors or warnings in this structure.
%
*/
static MagickBooleanType WriteCLIPImage(const ImageInfo *image_info,
  Image *image,ExceptionInfo *exception)
{
  Image
    *clip_image;

  ImageInfo
    *write_info;

  MagickBooleanType
    status;

  if (image->read_mask == MagickFalse)
    (void) ClipImage(image,exception);
  if (image->read_mask == MagickFalse)
    ThrowWriterException(CoderError,"ImageDoesNotHaveAClipMask");
  clip_image=GetImageMask(image,exception);
  if (clip_image == (Image *) NULL)
    return(MagickFalse);
  (void) CopyMagickString(clip_image->filename,image->filename,MagickPathExtent);
  write_info=CloneImageInfo(image_info);
  (void) SetImageInfo(write_info,1,exception);
  if (LocaleCompare(write_info->magick,"CLIP") == 0)
    (void) FormatLocaleString(clip_image->filename,MagickPathExtent,"miff:%s",
      write_info->filename);
  status=WriteImage(write_info,clip_image,exception);
  clip_image=DestroyImage(clip_image);
  write_info=DestroyImageInfo(write_info);
  return(status);
}
Beispiel #3
0
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                                                             %
%                                                                             %
%                                                                             %
%   R e a d C L I P I m a g e                                                 %
%                                                                             %
%                                                                             %
%                                                                             %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%  ReadCLIPImage returns the rendered clip path associated with the image.
%
%  The format of the ReadCLIPImage method is:
%
%      Image *ReadCLIPImage(const ImageInfo *image_info,
%        ExceptionInfo *exception)
%
%  A description of each parameter follows:
%
%    o image_info: the image info.
%
%    o exception: return any errors or warnings in this structure.
%
*/
static Image *ReadCLIPImage(const ImageInfo *image_info,
  ExceptionInfo *exception)
{
  Image
    *image;

  ImageInfo
    *read_info;

  /*
    Initialize Image structure.
  */
  assert(image_info != (const ImageInfo *) NULL);
  assert(image_info->signature == MagickSignature);
  if (image_info->debug != MagickFalse)
    (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
      image_info->filename);
  assert(exception != (ExceptionInfo *) NULL);
  assert(exception->signature == MagickSignature);
  read_info=CloneImageInfo(image_info);
  SetImageInfoBlob(read_info,(void *) NULL,0);
  (void) CopyMagickString(read_info->magick,"MIFF",MaxTextExtent);
  image=ReadImage(read_info,exception);
  read_info=DestroyImageInfo(read_info);
  if (image != (Image *) NULL)
    {
      Image
        *clip_image;

      (void) ClipImage(image);
      if (image->clip_mask == (Image *) NULL)
        ThrowReaderException(CoderError,"ImageDoesNotHaveAClipMask");
      clip_image=CloneImage(image->clip_mask,0,0,MagickTrue,exception);
      image=DestroyImage(image);
      image=clip_image;
    }
  return(GetFirstImageInList(image));
}
Beispiel #4
0
bool ImageManager::Init()
{
    // Version Check of DevIL
    if (ilGetInteger(IL_VERSION_NUM) < IL_VERSION /*|| iluGetInteger(ILU_VERSION_NUM) < ILU_VERSION || ilutGetInteger(ILUT_VERSION_NUM) < ILUT_VERSION*/)
    {
		printf ("DevIL library is out of date! Please upgrade\n");
		return false;
	}

    // Initilize all Devil components
    ilInit();
    //iluInit();
    //ilutInit();

    //ilutRenderer(ILUT_OPENGL);
    //ilutRenderer(ILUT_DIRECT3D9);

    //ilutEnable(ILUT_OPENGL_CONV);

    //ilEnable(IL_CONV_PAL);

    ilClearColour(0, 0, 0, 0);

    for(uint32_t i = 0; i < DATA->getNumTextures(); ++i)
    {
        if (DATA->getTextureData(i)->isLoneTexture())
        {
            ILuint DevilID = loadImage(DATA->getTextureData(i)->getPath(), false);
            DATA->getTextureData(i)->setDevILID(DevilID);
        }
    }

    for(uint32_t i = 0; i < DATA->getNumTextureGrids(); ++i)
    {
        TextureGridData* Grid = DATA->getTextureGridData(i);
        ILuint DevilID = loadImage(Grid->getPath(), false);

        uint16_t w = Grid->getTextureWidth();
        uint16_t h = Grid->getTextureHeight();

        std::vector<TextureData*> Textures = DATA->getTextureGridData(i)->TextureList;
        for (int j = 0; j < Textures.size(); j++)
        {
            ILuint NewID = ClipImage(DevilID, Textures[j]->getX(), Textures[j]->getY(), w, h);
            Textures[j]->setDevILID(NewID);
        }
    }

    for(uint32_t i = 0; i < DATA->getNumTextureSheets(); ++i)
    {
        TextureSheetData* Sheet = DATA->getTextureSheetData(i);
        ILuint DevilID = loadImage(Sheet->getPath(), false);

        std::vector<TextureData*> Textures = DATA->getTextureSheetData(i)->TextureList;
        for (int j = 0; j < Textures.size(); j++)
        {
            ILuint NewID = ClipImage(DevilID, Textures[j]->getX(), Textures[j]->getY(), Textures[j]->getW(), Textures[j]->getH());
            Textures[j]->setDevILID(NewID);
        }
    }

    return true;
}