U++ framework
Do not panic. Ask here before giving up.

Home » U++ Library support » Draw, Display, Images, Bitmaps, Icons » GIF reader BUG? Or BUG in inserting GIF into QTF?
BugQuestion.gif  GIF reader BUG? Or BUG in inserting GIF into QTF? [message #5675] Mon, 09 October 2006 11:40 Go to next message
temer is currently offline  temer
Messages: 5
Registered: October 2006
Location: Kyiv, Ukraine
Promising Member

Please, try the following code.

	String qtf;

	QtfRichObject PNGpict(RichObject("image",StoreImageAsString(StreamRaster::LoadFileAny("c:/msg_about.png"))));
	QtfRichObject GIFpict(RichObject("image",StoreImageAsString(StreamRaster::LoadFileAny("c:/msg_about.gif"))));

	qtf << "[A6 The PNG image looks well: " << PNGpict << "]&";
	qtf << "[A6 The GIF image looks tiny: " << GIFpict << "]&";

	PromptOK(qtf);


You will see that PNG image is OK, but the GIF image is only 2 pixels in height. What's the reason of this?

I used the follwing GIF: http://www.arilect.com/upp/forum/theme/default/images/msg_ab out.gif

The PNG file was created with MS Paint.
Re: GIF reader BUG? Or BUG in inserting GIF into QTF? [message #5716 is a reply to message #5675] Wed, 11 October 2006 07:41 Go to previous message
mirek is currently offline  mirek
Messages: 14290
Registered: November 2005
Ultimate Member
The problem (my fault) is that the size of image is created from "physical" size recorded in .gif, which is too small. When the image is converted to PNG, this info is lost (do not ask me why...) and the physical size is computed from "pixel" size (using 96DPI formula).

The necessary fix (which is useful anyway) is to introduce width/height parameters to CreateImageObject:

RichObject CreateImageObject(const Image& img, int cx, int cy)
{
	RichObject o = RichObject("image", StoreImageAsString(img));
	if(cx || cy)
		o.SetSize(GetRatioSize(o.GetPixelSize(), cx, cy));
	return o;
}


Note that you can leave cx or cy zero - image is then sized keeping the aspect ratio. If both are zero, "physical" size is used (as with recent version).

This code is now part of U++ and will be in the next release.

Mirek
Previous Topic: GetFontInfo without a Draw object?
Next Topic: Graphics Context and Draw Object
Goto Forum:
  


Current Time: Tue Apr 28 00:13:56 GMT+2 2026

Total time taken to generate the page: 0.00421 seconds