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
Solved

DirectX Draw Question - ?

Posted on 1997-09-01
5
342 Views
Last Modified: 2013-12-03
I use DirectX Draw in normal cooperative level mode and I need to blit off-screen surfaces onto primary. My off-screen surfaces are 8-bit palettized image data (with same palette as primary surface if video mode is in 8-bit palette). What I want to know is if the primary surface is in 16,24,32bit RGB, can I rely on the blitter to convert my offscreen surfaces to necessary RGB during blit? I don't mind if DirectX has to emulate the procedure if hardware doesn't support it but I don't want to have to code a 2nd alternative if it can't be done on certain user's systems. And DirectX SDK doesn't give me many clues.

If you are somewhat in the least unsure about the answer, PLEASE do not answer and let someone that knows for sure answer instead. I need a definitive answer since alot of work depends on your confidence in the subject.

Thanks
0
Comment
Question by:overworked
  • 3
  • 2
5 Comments
 
LVL 23

Accepted Solution

by:
chensu earned 150 total points
ID: 1405436
Yes, you can do it. Check out the DirectX sample "Donut". Set your display to 16,24,32-bit mode and run donut.exe. It works fine.
0
 

Author Comment

by:overworked
ID: 1405437
Thanks chensu. One more thing: Do the majority of video cards support this type of blit and if the video card doesn't, is the emulation operation tremendously slow. You may not know but I'm just wondering. Also, I know this wasn't included in the 150 pts but I've increased to 170 (all my pts for answer to this perhaps ez question): I also do direct writing to display surface and in 16/24/32 bit modes, are the pixels on screen in the same format? (I know they're not of course between 16 and 24 and 32 but what I mean is can I expect the format of for example the 32 bit value in 32 bit modes to be universal or must I obtain/consult a DDPIXELFORMAT for the primary surface. Thanks!
0
 

Author Comment

by:overworked
ID: 1405438
Well there goes my points again. You do this to me every time chensu. If you check donut.cpp you'll see that it calls DDLoadBitmap function which is found in ddutil.cpp (in ..\misc) to load the bitmaps. The bitmaps are StretchBlt from DIB hdc to the current Direct Draw hdc. This means that later on the off screen surfaces being blitted to primary are in the same format as the primary surface and not palettized, thus the blit is going from palettized to palettized, 16 to 16, 24 to 24, or 32 to 32 depending upon the current mode. All of this holds no significance to my question and I have no points to ask it again.
I thought perhaps that maybe this time, my additional clause in my original question would safegaurd me from this.
0
 
LVL 23

Expert Comment

by:chensu
ID: 1405439
I am sorry. Yes, you are right. In the sample "Donut", the conversion occurs when blitting from the memory DC to the off screen surface. When the off screen surface is created by CreateSurface(), it has the same format as the current primary surface. It seems that there is no such an example in the DirectX SDK samples. (The sample "Wormhole" loads the DIB data into an off screen surface directly, but it uses exclusive 640x480x8 mode.)

When you create such an off screen surface, you need to set the DDPIXELFORMAT ddpfPixelFormat according to your 8-bit palettized image data exactly. Also, you need to set the palette of the off screen surface using IDirectDrawSurface2::SetPalette. Then, when you blit the off screen surface to the primary surface, DirectX should do the conversion for you. I don't think it will be slow because the operation is not complicated. But, you should avoid it because the conversion occurs every time.

I am really sorry that I made a mistake.
0
 

Author Comment

by:overworked
ID: 1405440
no prob, thanks for the apology
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

This article describes a technique for converting RTF (Rich Text Format) data to HTML and provides C++ source that does it all in just a few lines of code. Although RTF is coming to be considered a "legacy" format, it is still in common use... po…
For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

856 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