BitBlt from mono to color bitmap

Win32 Programming

    Next

  • 1. Calculating text dimentions
    "Mehran Ziadloo" < XXXX@XXXXX.COM > wrote in message news: XXXX@XXXXX.COM ... > Hi, > I want to draw a text on a Bitmap object but I need to know about the text's > width and height to place it somewhere I like, and I need to know this > before I actually draw it since it affects its placement. > Well is it possible? Call GetTextExtentPoint32 with an hDc which has the appropriate font selected. -- - Gary Chanson (Windows SDK MVP) - Abolish Public Schools
  • 2. Title bar icon problem of WIN32 API MessageBox
    WIN32 API MessageBox just allows user to specify the big icon (MB_ICONWARNING, MB_ICONERROR, etc) in the message dialog, does anybody knows how to set or change the small icon on the left corner of the title bar of the message dialog? For example: MessageBox(hwnd, "some message", "title", MB_OK | MB_ICONINFORMATION); I want the message dialog to have the small icon of my application on the title bar.
  • 3. Problem using Generic printer driver, WinXP/WinNT
    How can I force TTY driver (generic printer driver) not to send FF at the end of page ? Actually, it remplaces LF-CR with FF on the last page, even though the print processor has been set to RAW (no FF appended nor FF Auto). It is also pretty "strange" (least I could say!) to see that the vertical metrics are wrong; each new line I send increments Printer.CurrentY by approximately 0.13889 inch, instead of 0.166667 inch, which makes it very awful to create forms for Windows, since vertical sizes cannot match. I forgot to mention that I'm programming using VB5. Sadly, Win98 TTY driver worked A LOT BETTER than WinNT and WinXP.
  • 4. How to do per-window gamma correction?
    Hello, Is there anyway to do gamma correction on a particular window using graphics card or DirectX support? I know it can be done on full screen using Get/SetDeviceGammaRamp functions. Your help is greatly appreciated. Regards Bala

BitBlt from mono to color bitmap

Postby Pedro Ferreira » Thu, 12 Apr 2007 23:57:23 GMT

Hi,

I have a monochrome bitmap that I get from an external device as a HBITMAP 
handle. Then I want to take that bitmap and draw some _color_ stuff on top 
of it.

My idea is to create a new color bitmap (24 bit), create a DC for use with 
it, and then BitBlt from the mono to the color bitmap. Although I'm not 
finding a way to create a color bitmap, to select it in a compatible DC.

I'm doing something like this:

////////////////////////////////////////
 rawBmp = CBitmap::FromHandle(myDeviceHBITMAP);
 rawBmp->GetBitmap(&rawBitmap);
 rawDC.CreateCompatibleDC(NULL);
 rawDC.SelectObject(rawBmp);

 processedDc.CreateCompatibleDC(NULL);
 processedBmp->CreateCompatibleBitmap(&processedDc, rawBitmap.bmWidth, 
rawBitmap.bmHeight);
 processedDc.SelectObject(processedBmp);

 processedDc.BitBlt(0, 0, rawBitmap.bmWidth, rawBitmap.bmHeight, &rawDC, 0, 
0, SRCCOPY);

//And now draw some _color_ stuff
////////////////////////////////////////

Now my problem is that the bitmap that I got in processedBmp is also mono. 
if I create a Bitmap using CreateBitmap and passing 24 in nBitcount, then I 
can't select it into the processedDC.

I'm not trying to alter the color of the rawBmp in any way. Just need to 
draw some color lines and circles on top of it in processedDC/processedBmp.

Any ideas?

Thanks,
Pedro 



RE: BitBlt from mono to color bitmap

Postby jetan » Fri, 13 Apr 2007 19:03:02 GMT

Hi Pedro,

As a quick information, using DIB section should give you more control.

Anyway, I will perform some further research to get more information for 
you. I will get back to you ASAP. Thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to 
 http://www.**--****.com/ #notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues 
where an initial response from the community or a Microsoft Support 
Engineer within 1 business day is acceptable. Please note that each follow 
up response may take approximately 2 business days as the support 
professional working with you may need further investigation to reach the 
most efficient resolution. The offering is not appropriate for situations 
that require urgent, real-time or phone-based interactions or complex 
project analysis and dump analysis issues. Issues of this nature are best 
handled working with a dedicated Microsoft Support Engineer by contacting 
Microsoft Customer Support Services (CSS) at 
 http://www.**--****.com/ 
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.



RE: BitBlt from mono to color bitmap

Postby jetan » Sat, 14 Apr 2007 18:31:01 GMT

Hi Pedro,

Sorry for letting you wait. I have discussed this issue with some 
experienced GDI developer in Microsoft. Below is his comment:


"The original question and code is not clear enough. We do not know the bit 
depth of rawDC, raBmp, etc. The code is not complete and it's using MFC 
wrapper classes.

The problem description "processedBmp is also mono" is also not clear 
enough. If the problem is about processedBmp is 1-bpp, we need to check how 
is this bitmap created. If the problem is that the result bitmap only has 
black/white color, we need to check background and foreground colors of the 
DC. 

If you use DIB section, then you have full control of bitmap color depth. 
Another benefits is that DIB section uses user mode address space memory, 
instead of more scarce kernel mode address space memory."

I hope you can provide more details for this issue. Thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to 
 http://www.**--****.com/ #notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues 
where an initial response from the community or a Microsoft Support 
Engineer within 1 business day is acceptable. Please note that each follow 
up response may take approximately 2 business days as the support 
professional working with you may need further investigation to reach the 
most efficient resolution. The offering is not appropriate for situations 
that require urgent, real-time or phone-based interactions or complex 
project analysis and dump analysis issues. Issues of this nature are best 
handled working with a dedicated Microsoft Support Engineer by contacting 
Microsoft Customer Support Services (CSS) at 
 http://www.**--****.com/ 
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.


RE: BitBlt from mono to color bitmap

Postby jetan » Wed, 18 Apr 2007 12:22:37 GMT

Hi Pedro,

Have you reviewed my reply to you? Have you managed to collect more 
information for your question? Please feel free to feedback the information 
and your concern, I will work with you, thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to 
 http://www.**--****.com/ #notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues 
where an initial response from the community or a Microsoft Support 
Engineer within 1 business day is acceptable. Please note that each follow 
up response may take approximately 2 business days as the support 
professional working with you may need further investigation to reach the 
most efficient resolution. The offering is not appropriate for situations 
that require urgent, real-time or phone-based interactions or complex 
project analysis and dump analysis issues. Issues of this nature are best 
handled working with a dedicated Microsoft Support Engineer by contacting 
Microsoft Customer Support Services (CSS) at 
 http://www.**--****.com/ 
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.



Re: BitBlt from mono to color bitmap

Postby Pedro Ferreira » Wed, 18 Apr 2007 22:13:15 GMT



Hello Jeffrey, I'm sorry for the late reply and for not providing enough 
information in my first question.

After some more research, I found that my problem was on creating a 
24bit bitmap that was compatible with a DC created with CreateCompatibleDC.

When I tried the DIB solution it worked as expected. I first created a 
DIB with 24bit, and after that, I was able to select it into the created DC.

Another thing I wasn't sure was how the black and white colors would 
"translate" into other colors in the 24bit DC, but thanks to your reply, 
I figured it was just a matter of setting the backround and foreground 
colors on the destination DC.

So, its all solved now. I'm not sure if I can post the solution here, 
because the code is quite big, and not easy to pick some isolated piece 
from there, but I can try to make an example, if needed.

Thanks again for your help, and for forwarding the question to another 
developer.

Pedro Ferreira

Re: BitBlt from mono to color bitmap

Postby jetan » Thu, 19 Apr 2007 16:38:01 GMT

Hi Pedro,

Glad to see your problem is resolved. 

Yes, you may share your solution here if you think it will benefit the 
entire community. Thanks.

If you need further help, please feel free to post, thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to 
 http://www.**--****.com/ #notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues 
where an initial response from the community or a Microsoft Support 
Engineer within 1 business day is acceptable. Please note that each follow 
up response may take approximately 2 business days as the support 
professional working with you may need further investigation to reach the 
most efficient resolution. The offering is not appropriate for situations 
that require urgent, real-time or phone-based interactions or complex 
project analysis and dump analysis issues. Issues of this nature are best 
handled working with a dedicated Microsoft Support Engineer by contacting 
Microsoft Customer Support Services (CSS) at 
 http://www.**--****.com/ 
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.




Return to Win32 Programming

 

Who is online

Users browsing this forum: No registered users and 80 guest