Alien-FreeImage

 view release on metacpan or  search on metacpan

src/Source/FreeImage/PluginG3.cpp  view on Meta::CPAN

		uint32 linesize = TIFFhowmany8(xsize);

		// fill the bitmap structure ...
		// ... palette
		RGBQUAD *pal = FreeImage_GetPalette(dib);
		if(photometric_in == PHOTOMETRIC_MINISWHITE) {
			pal[0].rgbRed = pal[0].rgbGreen = pal[0].rgbBlue = 255;
			pal[1].rgbRed = pal[1].rgbGreen = pal[1].rgbBlue = 0;
		} else {
			pal[0].rgbRed = pal[0].rgbGreen = pal[0].rgbBlue = 0;
			pal[1].rgbRed = pal[1].rgbGreen = pal[1].rgbBlue = 255;
		}
		// ... resolution
		FreeImage_SetDotsPerMeterX(dib, (unsigned)(resX/0.0254000 + 0.5));
		FreeImage_SetDotsPerMeterY(dib, (unsigned)(resY/0.0254000 + 0.5));

		// read the decoded scanline and fill the bitmap data
		FreeImage_SeekMemory(memory, 0, SEEK_SET);
		BYTE *bits = FreeImage_GetScanLine(dib, rows - 1);
		for(int k = 0; k < rows; k++) {
			FreeImage_ReadMemory(bits, linesize, 1, memory);
			bits -= pitch;
		}

		// free the TIFF wrapper
		TIFFClose(faxTIFF);

		// free the memory buffer
		FreeImage_CloseMemory(memory);

	} catch(const char *message) {
		if(memory) FreeImage_CloseMemory(memory);
		if(faxTIFF) TIFFClose(faxTIFF);
		if(dib) FreeImage_Unload(dib);
		FreeImage_OutputMessageProc(s_format_id, message);
		return NULL;
	}

	return dib;

}

// ==========================================================
//   Init
// ==========================================================

void DLL_CALLCONV
InitG3(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 = NULL;
	plugin->validate_proc = NULL;
	plugin->mime_proc = MimeType;
	plugin->supports_export_bpp_proc = SupportsExportDepth;
	plugin->supports_export_type_proc = NULL;
	plugin->supports_icc_profiles_proc = NULL;
}



( run in 0.795 second using v1.01-cache-2.11-cpan-d7f47b0818f )