|
-
Nov 2nd, 2002, 09:17 AM
#1
Thread Starter
Ex-Super Mod'rater
Using a DC instead of Picture1.Picture
I've used the code below to fill "bmp" with the details about the picture in "Picture1".
VB Code:
Private Type BITMAP
bmType As Long
bmWidth As Long
bmHeight As Long
bmWidthBytes As Long
bmPlanes As Integer
bmBitsPixel As Integer
bmBits As Long
End Type
Private bmp As BITMAP
GetObjectA Picture1.Picture, Len(bmp), bmp
The problem is i'm no longer wanting to use a PicBox and have stored a picture in a DC I created instead. Does anyone know if there is a way to get these details from just the DC, The only part of "bmp" that I really need is "bmp.bmBits".
Thanx to anyone that can help.
Last edited by Electroman; Nov 2nd, 2002 at 03:01 PM.
When your thread has been resolved please edit the original post in the thread (  )
and amend "-[RESOLVED]-" to the end of the title and change the icon to  , Thank you.
When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

-
Nov 2nd, 2002, 10:24 AM
#2
Addicted Member
I am just learning VB and bitmaps but the way I do what you're trying to do is:
VB Code:
Dim bmBits As Byte
f = FreeFile
Open strFile For Binary As #f
Get #f, 29, bmBits
Close #f
-
Nov 2nd, 2002, 10:38 AM
#3
Thread Starter
Ex-Super Mod'rater
I've sort of solved the problem but it seems as if there should be a better way to do this. Anyway this is how i'v managed it:
VB Code:
Private Type OffScreenDC
DC As Long
Object As IPictureDisp
End Type
Private MyPict as OffScreenDC
I used this to create the DC:
VB Code:
'Create compatible DC
MyPict.DC = CreateCompatibleDC(frmMain.hdc)
'Load bitmap
Set MyPict.Object = LoadPicture(iFilename)
SelectObject MyPict.DC, MyPict.Object
nFirst = True
Then I used the "MyPict.Object" instead of the Picture1.Picture:
VB Code:
GetObjectAPI MyPict.Object, Len(bmp), bmp
Only thing is now I need to keep the IPictureDisp type when before I was getting rid of it once i had loaded the picture, so my question now is does anyone know if I can regain the IPictureDisp type for a DC when I need it because I might not always use a file to fill a DC.
Thanx sequoyan, I'll look into that as well, but the thing is i'm trying to work with a loaded Bitmap and bmp.bmBits points to where in the memory the data is(I think).
Last edited by Electroman; Nov 2nd, 2002 at 03:02 PM.
When your thread has been resolved please edit the original post in the thread (  )
and amend "-[RESOLVED]-" to the end of the title and change the icon to  , Thank you.
When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

-
Nov 2nd, 2002, 10:44 AM
#4
Addicted Member
Sure, anytime. I'm just starting to learn DCs so what you're trying to do is a little beyond me.
But if it helps at all, and if you didn't already know it, byte 29 is the bit depth.
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
|