PRC9108007: C 5.1 _putimage() May Fail if Image Height = 1

ID Number: Q75251

5.00 5.10

MS-DOS

buglist5.00 buglist5.10 fixlist6.00

Summary:

PROBLEM ID: C9108007

SYMPTOMS

In the Microsoft C Compiler versions 5.0 and 5.1 and in the

Microsoft QuickC Compiler versions 2.0 and 2.01, the function

_putimage() fails to transfer an image to the screen when the image

has a height of 1 (that is, a line) and the upper left corner is

specified as 0 in the second parameter.

RESOLUTION/STATUS

When the height of the image is greater than 1, or the upper left

corner is specified to be anything other than 0, the function

behaves as expected.

Microsoft has confirmed this to be a problem in C versions 5.0 and

5.1 and QuickC versions 2.0 and 2.01 (buglist2.00 and buglist2.01).

This problem was corrected in C version 6.0 and QuickC version 2.5

(fixlist2.50).

More Information:

The following code demonstrates the problem in C versions 5.0 and 5.1

and in QuickC versions 2.0 and 2.01. In C 6.0 and QuickC 2.5, the

image is drawn as expected.

Sample Code

-----------

// Compile options needed: none

#include <graph.h>

#include <malloc.h>

#include <conio.h>

void main(void);

void main( )

{

char *buffer;

_setvideomode( _VRES16COLOR );

buffer = (char *) malloc( (size_t) _imagesize( 5, 0, 200, 0 ) );

// If space was allocated, draw a horizontal line 50 pixels down,

// copy the image, and place it at the top of the screen. Note that

// the 2nd parameter to _putimage is 0, so this will fail under C 5.0

// and 5.1 and QuickC 2.0 and 2.01.

if( buffer )

{

_setcolor( 1 );

_moveto( 5, 50 );

_lineto( 200, 50 );

_getimage( 5, 50, 200, 50, buffer );

_putimage( 5, 0, buffer, _GPSET );

while( !kbhit( ) );

}

_setvideomode( _DEFAULTMODE );

}

Additional reference words: 2.00 2.50 5.00 5.10 6.00