Quality less

Discussions on GFL SDK, the graphic library for reading and writing graphic files

Moderators: XnTriq, xnview

Post Reply
RankoR
Posts: 1
Joined: Wed Apr 21, 2010 5:01 pm

Quality less

Post by RankoR » Wed Apr 21, 2010 5:07 pm

Hello! I use GFL SDK for some manipulations with Black & White JPEG pictures. But when I just load and save picture without changing something, I'm getting strongly "spoiled" image.
Here're load and save procedure's parts.

Code: Select all

GFL_BITMAP *bitmap = gflAllockBitmap(GFL_BINARY, 200, 120, 1, NULL); //!!!!!
	if ( bitmap == NULL )
		return NULL;

	GFL_FILE_INFORMATION info;
	GFL_LOAD_PARAMS params;
	memset(&params, 0, sizeof(GFL_LOAD_PARAMS));
	gflGetDefaultLoadParams(&params);
	params.Flags = GFL_LOAD_BINARY_AS_GREY;
	params.FormatIndex = -1;
	params.Origin = GFL_TOP_LEFT;
	params.ColorModel = GFL_RGB;
	params.LinePadding = 1;
	params.DefaultAlpha = 0x00;
	params.Width = 200; 
	params.Height = 120; 

	if ( gflLoadBitmap(fName, &bitmap, &params, &info) != GFL_NO_ERROR )
		return NULL;

........................................

Code: Select all

bool _fastcall saveImage(char *fName, const GFL_BITMAP &bitmap)
{
	GFL_SAVE_PARAMS saveParams;
	memset(&saveParams, 0, sizeof(GFL_SAVE_PARAMS));
	saveParams.Flags = GFL_SAVE_ANYWAY;
	saveParams.Compression = GFL_NO_COMPRESSION;
	saveParams.Quality = 0;
	saveParams.Progressive = true;
	if ( gflSaveBitmap(fName, &bitmap, &saveParams) != GFL_NO_ERROR )
		return false;

	return true;
}
Can you help me?
// Sorry for my bad English =(

User avatar
dominique
Posts: 72
Joined: Thu Nov 08, 2007 9:22 am

Re: Quality less

Post by dominique » Wed Apr 21, 2010 9:31 pm

Given my experience, loading an image with gfl is extremely simple, the lib will find all what it need int the file header.
So, after loading default load parameters, try to specify this params.Flags only:

You should specify the FormatIndex of the save parameters and then the compression, CompressionLevel or quality depending on the format.

Hope it helps.
Dom

Post Reply