|
-
Jun 6th, 2002, 01:48 AM
#1
Bitmaps, APIs, PictureBoxes = Frustrating
Hey all. I've been beating this thing over and over, and I still don't know what's occuring.
I'm trying to get my function to load up an entire bitmap image within the space of the picturebox (ie: a thumbnail.) So far, I've been able to get the image into the box, but I can't figure a way around the color appearance. When I load a 24-bit bmp, it still displays it like a 8-bit! How do I fix this?
Here's the code I'm using (at the moment):
VB Code:
Public Function DisplayBMP(picBox As PictureBox, fileName As String) As Boolean
Dim hDC As Long, hBMP As Long
Dim fileNo As Integer, counter As Integer
Dim imgSize As POINT
DisplayBMP = False
fileNo = FreeFile
Open fileName For Binary As fileNo
Get #fileNo, 19, imgSize
Close fileNo
counter = 0
Do
hDC = CreateCompatibleDC(picBox.hDC)
counter = counter + 1
Loop While hDC < 1 Or counter < 15
If hDC < 1 Then
MsgBox "Failed on Device Context creation"
Exit Function
End If
hBMP = LoadImage(0, fileName, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE Or LR_DEFAULTSIZE)
If hBMP = 0 Then
DeleteDC hDC
MsgBox "Failed to load the image"
Exit Function
End If
SelectObject hDC, hBMP
DeleteObject hBMP
StretchBlt picBox.hDC, 0, 0, picBox.Width, picBox.Height, hDC, 0, 0, imgSize.X * 15, imgSize.Y * 15, vbSrcCopy
picBox.Refresh
DeleteDC hDC
End Sub
Any help on how to fix my color problem, or on how to better implement this, is greatly appreciated.
Destined
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|