Microsoft KB Archive/70362

{|
 * width="100%"|

_pg_setpalette Causes Incorrect Display for Extended ASCII

 * }

Q70362

6.00 6.00a 6.00ax 7.00 | 1.00 1.50 MS-DOS | WINDOWS kbprg -- The information in this article applies to: - The C Run-time (CRT), included with: - Microsoft C for MS-DOS, versions 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 -- SUMMARY ======= When attempting to reset the Presentation Graphics palette to display an extended ASCII character as a plotted point, a different character may be printed than expected. This problem occurs with the _pg_setpalette function in C versions 6.0, 6.0a, 6.0ax, C/C++ version 7.0, Visual C++ version 1.0, and QuickC versions 2.5 and 2.51 [but not with the _pg_setpalette function in QuickC versions 2.0 and 2.01]. MORE INFORMATION ================ The _pg_setpalette function sets a palette that is used by the presentation graphics routines. This palette contains colors, line styles, fill patterns, and plot characters specifically defined by the user. When defining these plot characters with extended ASCII characters, the actual character displayed may be different than what was defined. The sample code below demonstrates this problem. Note that the ASCII character displayed incorrectly is ASCII 254. All extended ASCII characters of value 175 and below seem to be displayed correctly; however, most characters above 175 are displayed incorrectly, usually as single dashes. This problem is occurring because with QuickC versions 2.5 and later, and C versions 6.0 and later, characters are based on the ANSI character set, and the actual implementation of additional characters are undefined (Section 2.2.1). The ANSI character set consists of all uppercase and lowercase letters, decimal digits 0 - 10, and the following graphics characters: ! &quot; # % & ' * +, -. / : ; < = > ? [ \ ] _ { | } ~ When using the CodeView debugger and setting a watch on pal[1].plotchar, it can be seen that the correct value is being placed in memory. However, _pg_setpalette does not initialize this value correctly for the presentation graphics functions. Sample Code --- /* Compiler options needed: none */ #include #include #include #include #define VALUES 5 float _far xvals[VALUES] = {1.0f, 2.0f, 3.0f, 4.0f, 5.0f}; float _far yvals[VALUES] = {11.0f, 9.0f, 12.0f, 8.0f, 5.0f}; void main(void) { chartenv env; palettetype pal; _setvideomode(_MAXRESMODE); _pg_initchart; _pg_defaultchart( &env, _PG_SCATTERCHART, _PG_POINTANDLINE ); _pg_getpalette((paletteentry _far *)pal); pal[1].plotchar = 254; /* This value does not get */ /* printed correctly */ _pg_setpalette((paletteentry _far *)pal); _pg_chartscatter(&env, xvals, yvals, VALUES); getch; _setvideomode(_DEFAULTMODE); } Additional reference words: kbinf 6.00 6.00a 6.00ax 7.00 1.00 1.50 pgchart KBCategory: kbprg KBSubcategory: CRTIss GraphicsIss

Keywords : kb16bitonly

Issue type :

Technology : kbVCsearch kbAudDeveloper kbCRT