Mapping Bitmap Background Colors to System Colors 
Author Message
 Mapping Bitmap Background Colors to System Colors

I am hoping that someone out there can shed some light on a problem that
I have spent days on.

In my Visual Basic 4.0 application I have a 3D logo that I want to display
on a form.
The logo is stored in a BMP as ADS3D.BMP.  The problem is I want the colors
in the BMP
to automatically map to the appropriate 3D system colors.  As documented,
the API call
LoadImage with the LR_LOADMAP3DCOLORS option appears to do what I want.  I
have had
difficulties implementing it.  The code listed below is what I came up with
after talking
to Microsoft.  It should Load the image from the BMP file and transfer it
to the bitmap
that is already displayed.  That's what it SHOULD do, I actually get no
visible results in
my VB application.

Declare Function LoadImage Lib "user32" Alias "LoadImageA" (ByVal hInst As
Long, ByVal lpsz As String, ByVal un1 As Long, ByVal n1 As Long, ByVal n2
As Long, ByVal un2 As Long) As Long
Declare Function CreateCompatibleDC Lib "gdi32" (ByVal hdc As Long) As Long
Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject
As Long) As Long
Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal X As
Long, ByVal Y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal
hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As
Long) As Long
Declare Function DeleteDC Lib "gdi32" (ByVal hdc As Long) As Long
Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
Public ImageHandle As Long

Dim CompatibleDC As Long, OldHGDIOBJ As Long, Success As Long
' Load logo image from file and do 3DMAPCOLOR translation
ImageHandle = LoadImage(APP.hInstance, "ADS3D.BMP", 0, 150, 75, &H1030)
CompatibleDC = CreateCompatibleDC(bmpLogo.hdc) ' Create device context for
source bitmap
OldHGDIOBJ = SelectObject(CompatibleDC, ImageHandle)
Success = BitBlt(bmpLogo.hdc, 0, 0, 150, 75, CompatibleDC, 0, 0, &HCC0020)
' Copy image
Success = SelectObject(CompatibleDC, OldHGDIOBJ) ' Restore original
Success = DeleteDC(CompatibleDC) ' delete device context

If anyone could help me out it would be greatly appreciated, I am open to
other
ideas as well.



Sun, 10 Jan 1999 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Bitmap background color in msflexgrid

2. Bitmap background color in msflexgrid

3. Bitmap background color in msflexgrid/mshflexgrid controls

4. Bitmap Color Palette editing-VB4 16 bit 256 color

5. Bitmap Color Palette editing-VB4 16 bit 256 color

6. Change the color of form's caption (background and font color)

7. ListView selection color (NOT Background color)

8. Display Only Text Box - Text Color/Background Color

9. BMP - change color based on form's background color

10. BMP - change color based on form's background color

11. How to implement system background color

12. Creating bitmap with windows system color

 

 
Powered by phpBB® Forum Software