Microsoft KB Archive/67759

{|
 * width="100%"|

PRB: _getpixel Return Value Unchanged After _setbkcolor

 * }

Q67759

5.10 6.00 6.00a 6.00ax 7.00 | 1.00 1.50 MS-DOS | WINDOWS kbprg kbprb -- The information in this article applies to: - The C Run-time (CRT), included with: - Microsoft C for MS-DOS, versions 5.1, 6.0, 6.0a, and 6.0ax - Microsoft C/C++ for MS-DOS, version 7.0 - Microsoft Visual C++ for Windows, versions 1.0 and 1.5 -- SYMPTOMS ======== In an MS-DOS application, the _getpixel function always returns the value zero (0) when the specified pixel is drawn in the background color. Using the _setbkcolor function to change the color of the background does not affect the return value from _getpixel. CAUSE ===== The _getpixel function returns the color index for the specified pixel, not the value for the color mapped to a particular color index. The background color in graphics mode is always mapped to palette entry 0. RESOLUTION ========== If the application changes the color index for a particular point on the screen, the _getpixel function returns a different value. Specify the desired color index with the _setcolor function and call one of the graphics drawing functions, such as _floodfill, _setpixel, and so on. MORE INFORMATION ================ The following code example demonstrates this situation. Sample Code --- /* Compile options needed: none * Link options needed: GRAPHICS.LIB */ // Note: C 5.1 does not support _MAXRESMODE #include #include void main(void) { short xvar = 100, yvar = 100, result1 = 0, result2 = 0; _setvideomode(_MAXRESMODE); result1 = _getpixel(xvar, yvar); _setbkcolor(_BLUE); result2 = _getpixel(xvar, yvar); _setvideomode(_DEFAULTMODE); printf(&quot;Before _setbkcolor - %d\n&quot;, result1); printf(&quot;After _setbkcolor - %d\n&quot;, result2); } Additional reference words: 6.00 6.00a 6.00ax 7.00 1.00 1.50 KBCategory: kbprg kbprb KBSubcategory: CRTIss GraphicsIss

Keywords : kb16bitonly

Issue type :

Technology : kbVCsearch kbAudDeveloper kbCRT