Problem with Quickwin routine SAVEIMAGE and workaround

Problem with Quickwin routine SAVEIMAGE and workaround

I often use the routine SAVEIMAGE to save an entire window image to a file. When printing that image, or inserting it into a Word document etc., black lines always appear along the right and bottom edges. I have figured out why and how to fix it.

If the window size is, say, NXPIXELS x NYPIXELS, and code is for example

NXPIXELS = 800
NXPIXELS = 600
I4 = SAVEIMAGE (FILENAME, 0,0, NXPIXELS, NYPIXELS)

you will find that the resulting image is actually 801 x 601, and the extra pixels at the right and bottom are black! The problem can be fixed by

 I4 = SAVEIMAGE (FILENAME, 0,0, NXPIXELS-1, NYPIXELS-1) 

In defence of Intel, the documentation is a little nebulous about the arguments defining a "bounding rectangle" around the desired part of the window image, but in my opinion this is a bug and should be fixed--or at least include a warning about what happens when you try to save an entire window. (I have not investigated what happens when you save a portion of a window, or use 1,1 as the upper left corner instead of 0,0.)

2 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

On reflection, I'm not sure I can blame Intel's documentation at all. I note that when a window is created, you specify NUMXPIXELS, NUMYPIXELS. The address of the upper left corner is (0, 0) and the address of the lower right corner is (NUMXPIXELS-1, NUMYPIXELS-1). So when you ask to save an image as I did above, you are actually asking for a size of 801 x 601. What else can the compiler do but make the extra pixels black? So the proper statement is

I4 = SAVEIMAGE (FILENAME, 0,0, NXPIXELS-1, NYPIXELS-1)

and this is simply the prudent thing to do. I only wish that the documentation for SAVEIMAGE explained this a bit. An example would be good.

 

Leave a Comment

Please sign in to add a comment. Not a member? Join today