Exemplo n.º 1
0
static VALUE save(VALUE self, VALUE _output) {
  char * output = STR2CSTR(_output);

        FREE_IMAGE_FORMAT fif = FreeImage_GetFIFFromFilename(output);
        if (fif == FIF_UNKNOWN) fif = FIX2INT(rb_iv_get(self, "@file_type"));
        if ((fif != FIF_UNKNOWN) && FreeImage_FIFSupportsWriting(fif)) { 
          GET_BITMAP(bitmap);
          int flags = fif == FIF_JPEG ? JPEG_QUALITYSUPERB : 0;
          if (fif == FIF_PNG) FreeImage_DestroyICCProfile(bitmap);
          return (FreeImage_Save(fif, bitmap, output, flags) ? Qtrue : Qfalse);
        }
        rb_raise(rb_eTypeError, "Unknown file format");
      }
Exemplo n.º 2
0
FIICCPROFILE * DLL_CALLCONV
FreeImage_CreateICCProfile(FIBITMAP *dib, void *data, long size) {
	// clear the profile but preserve profile->flags
	FreeImage_DestroyICCProfile(dib);
	// create the new profile
	FIICCPROFILE *profile = FreeImage_GetICCProfile(dib);
	if(size && profile) {
		profile->data = malloc(size);
		if(profile->data) {
			memcpy(profile->data, data, profile->size = size);
		}
	}
	return profile;
}