Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

A question in DirectDraw

Posted on 1998-12-12
4
Medium Priority
?
297 Views
Last Modified: 2013-11-20
I'm building a WINDOWED DirectDraw program to show some 256 gray level images. I create two surfaces: a primary surface and a offscreenplane surface with size of 512*512. Now, I use Lock(...) method to get a pointer (lpSurface) to the offscreenplane surface and render to this surface directly. That is, I write the color index data directly to the surface using the pointer. After rendering, I Unlock it and use Blt(...) method to transfer data in offscreenplane surface to primary surface to show the image in screen.
I also create a 256 gray level pallete and set it to both these two surface. But when I run this program, the 20 static system colors are shown in my images replacing the gray level of 0-9 and 246-255. What shall I do to correct this error?
Thank you!
0
Comment
Question by:zwwise
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 5

Expert Comment

by:scrapdog
ID: 1326102
It is not an error.  It is part of DirectDraw's design.  You are going to have to let Windows keep those 20 colors, and get by with 236 colors.  

"Consideration number two—and this is a big one—is the 20 system or "static" colors that Windows reserves unto itself.. It guards these jealously, and if your game uses 256 different colors, it's too bad for you—20 of those colors will be mapped to the reserved colors, with results that may or may not be pleasing to the eye. So you have to either restrict your artists to 236 colors, or ensure that the static colors are present in the palette for every scene. For maximum performance you also want to ensure that the static colors are in the palette slots where Windows expects to find them. See Chapter 6 of Animation Techniques in Win32 for details on how to create an "identity palette" that has the static colors in the correct positions. "

Source:  http://www.microsoft.com/DEVNEWS/JanFeb97/MOBYGAME3.HTM
0
 
LVL 5

Expert Comment

by:scrapdog
ID: 1326103
I would recommend reading that entire page, so you will know about any other potential limitations.
0
 

Author Comment

by:zwwise
ID: 1326104
If I use the method of writing directly to offscreen as discribed above, is there no way to get rid of the 20 static colors displaying in my image? What shall I do to show my 256 gray image correctly using direct access method?
0
 

Accepted Solution

by:
JoeDol earned 20 total points
ID: 1326105
Well its seems you don't want to see the thruth. The situation is that if you are in windowed mode and there is simply no way to access the full 256 colors. Why ? Because in windowed mode you rely on the GDI palette management scheme. Which is cool for some stuff, but not very usefull in your case. The best you can do is using the SetSystemPaletteUse() function with the SYSPAL_NOSTATIC flag. This will allow you to use the entry [1..254] in the palette. The 0 and 255 entries are still locked by GDI. They contains black and white. So you might get what you are looking for, as you want to display a gray-level picture, I assume you have entries for black and white. Simply ensure that your entries map to the windows static ones.
An other solution is trying to look if you may run in a true color mode.
Also by experience, I know that you can reduce the number of colors in your image to 236 without noticeable degradation, after all you already reduced the number of different tones from some thousand probably to 256... And is you use the 236, you can still let the 20 windows static colors.


0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question