[chaoscope] Re: Image Sizes

  • From: Chaoscope <chaoscope@xxxxxxxxxxxxxx>
  • To: chaoscope@xxxxxxxxxxxxx
  • Date: Wed, 12 May 2004 23:55:47 +0100

Hi,

Regarding the previous post about image sizes on the large end, what
about on the small end?

 Try creating an image that is 0 x 0 - it works and even allows you to F3
 and F4.  Saving the image, on the other hand, saves a 0 kb file.

Imagine the amount of 0 x 0 images you could fit in a web gallery!

 -1 x -1 works as well, will allow you F3, F4, and save, but when you
 save you save an all black, 65532 x 1, 192 kb, file.

 Last test this early morning (it's almost five in the morning here - I
 woke up with Chaoscope on the brain and had to do these few tests ;) ) -
 create a new -10 x -10 image or -100 x -100 image - where's the window
 (the smaller one with the image, not the larger one)?  Note that the
 Width/Height fields display correctly (in that only positive values can
 be used) but also incorrectly (in that they are not the actual size of
 the window...) - where are the height/width values coming from?  Are
 they abs() after being passed from the image window?

It's a long story. The drawing interface is a class derived from TBitmap, which is Borland VCL encapsulation of a Windows Bitmap resource. I leave the height as it is and pass it on to the base class, the property is an int so negative values are possible, although you'd expect a C++ exception when the height is set to 0 or less.


The three lowest bits of the width value are cleared because OpenGL viewport width must be a multiple of 8 (or had to be on my previous graphic card implementation of OpenGL). They're cleared using a mask (0xFFFC or 65532) which also truncate the value to 16 bits, but remains an int, hence the sign change. A similar kludge caused the crash of the first Ariane 5.

I admit there's very little testing done on Width/Height values. "None" would be more accurate. I just make sure there's no memory allocated if the height or the width are negative.

Nicolas Desprez
======================================================
The Chaoscope mailing-list
Archives : //www.freelists.org/archives/chaoscope
Admin contact : chaoscope@xxxxxxxxxxxxxx
Web site : http://www.chaoscope.org
======================================================

Other related posts: