Alien-FreeImage
view release on metacpan or search on metacpan
src/Source/FreeImage/PluginPFM.cpp view on Meta::CPAN
if((image_type != FIT_RGBF) && (image_type != FIT_FLOAT)) {
return FALSE;
}
unsigned width = FreeImage_GetWidth(dib);
unsigned height = FreeImage_GetHeight(dib);
unsigned lineWidth = FreeImage_GetLine(dib);
// save image as Little Endian
const float scalefactor = -1.0F;
char buffer[PFM_MAXLINE]; // temporary buffer whose size should be enough for what we need
// Find the appropriate magic number for this file type
char magic = 0;
switch(image_type) {
case FIT_RGBF:
magic = 'F'; // RGBF
break;
case FIT_FLOAT:
magic = 'f'; // float greyscale
break;
default:
return FALSE;
}
// Write the header info
sprintf(buffer, "P%c\n%d %d\n%f\n", magic, width, height, scalefactor);
io->write_proc(&buffer, (unsigned int)strlen(buffer), 1, handle);
// Write the image data
for (unsigned y = 0; y < height; y++) {
BYTE *bits = FreeImage_GetScanLine(dib, height - 1 - y);
io->write_proc(bits, 1, lineWidth, handle);
}
return TRUE;
}
// ==========================================================
// Init
// ==========================================================
void DLL_CALLCONV
InitPFM(Plugin *plugin, int format_id) {
s_format_id = format_id;
plugin->format_proc = Format;
plugin->description_proc = Description;
plugin->extension_proc = Extension;
plugin->regexpr_proc = RegExpr;
plugin->open_proc = NULL;
plugin->close_proc = NULL;
plugin->pagecount_proc = NULL;
plugin->pagecapability_proc = NULL;
plugin->load_proc = Load;
plugin->save_proc = Save;
plugin->validate_proc = Validate;
plugin->mime_proc = MimeType;
plugin->supports_export_bpp_proc = SupportsExportDepth;
plugin->supports_export_type_proc = SupportsExportType;
plugin->supports_icc_profiles_proc = NULL;
plugin->supports_no_pixels_proc = SupportsNoPixels;
}
( run in 0.863 second using v1.01-cache-2.11-cpan-d7f47b0818f )