-
Pictures
Hi everyone, yet another question from me :)
I'm messing around bit with graphics and stuff, I got this:
Code:
Dim TmpPictureBox as Picturebox
Is there any way that I can use this picturebox for drawing? When i try to it gives all kind of nice errors :D
I want to do some drawing inside a function on such a picturebox and then return that picturebox's picture property. I hope I made myself clear and that anyone knows how to fix this.
-Shell-
-
Ok, i'll change the question.
I'm making a graphics file format (nothing serious, just playing around). I want to make a function where you input a filename and the function then returns a picture. Like this:
Code:
Public Funtion OpenGraphicFile(sFileName as String) as picture
'Do drawing and loading stuff
End Function
How can I make a picture with the right sizes (stored in the file) wich I can return with this function? I want to use the function like this:
Code:
Picture1.picture = OpenGraphicFile("c:\test.grp")
I know i'll have to use the createbitmap api and some other, but i have no clue on how to use those! Anyone please help me :)
Thanks in advance,
-Shell-
-
you could make a graphic format if you know some your binary open commands. And if you plan the structure of your format.
ill look into what your trying to do with the picture.
-
The PictureBox only supports certain formats so your function would have to return something that the control supports. Since that's the case, why go to all the trouble of developing your own file format. Also, for your first question, try this:
Dim TmpPictureBox as StdPicture
-
Hi,
What I want to do is:
Make a bitmap with given size in memory wich I can draw on using setpixelv and wich I can return from a function so it can be put in a picturebox.
-Shell-
-
Ok... i've been doing some trying and searching and i now have this:
Code:
Dim MyDC As Long
Dim hBitmap As Long
Dim Pic As New StdPicture
Set Pic = LoadPicture("")
'Create a DC
MyDC = CreateCompatibleDC(GetDC(0))
'Create a bitmap
hBitmap = CreateCompatibleBitmap(GetDC(0), 32, 32)
'Select the bitmap in the DC
SelectObject MyDC, hBitmap
BitBlt MyDC, 0, 0, 32, 32, Picture1.hdc, 0, 0, SRCCOPY
This creates a 32x32 image, now my question is: How can i put this picture into the stdPicture thing? I tried this: pic.handle = MyDC, but that wouldn't work. Anyone knows? Please help me!! :)
-Shell-
-
Here's a function create an stdPicture using the handle of a bitmap using the OleCreatePictureIndirect API
Code:
Public Type GUID
Data1 As Long
Data2 As Integer
Data3 As Integer
Data4(7) As Byte
End Type
Public Type PicBmp
Size As Long
Type As Long
hBmp As Long
hPal As Long
Reserved As Long
End Type
Declare Function OleCreatePictureIndirect Lib "olepro32.dll" (PicDesc As PicBmp, RefIID As GUID, ByVal fPictureOwnsHandle As Long, iPic As IPicture) As Long
Private Function BitmapToStdPicture(hMemBmp As Long) As StdPicture
Dim InterfaceId As GUID
Dim Pic As PicBmp
Dim iPic As StdPicture
With InterfaceId
.Data1 = &H20400
.Data4(0) = &HC0
.Data4(7) = &H46
End With
With Pic
.Size = Len(Pic)
.Type = vbPicTypeBitmap
.hBmp = hMemBmp
End With
OleCreatePictureIndirect Pic, InterfaceId, 1, iPic
Set LoadMemoryBitmap = iPic
End Function