|
-
Oct 28th, 2002, 10:18 AM
#1
Thread Starter
Addicted Member
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 
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-
Last edited by Shell; Oct 29th, 2002 at 04:02 PM.
-
Oct 28th, 2002, 02:29 PM
#2
Thread Starter
Addicted Member
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-
-
Oct 28th, 2002, 11:09 PM
#3
Addicted Member
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.
Using:
Visual Studio .Net Enterprise
Visual Basic 6.0 Enterprise
-
Oct 28th, 2002, 11:26 PM
#4
Addicted Member
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
-
Oct 29th, 2002, 01:50 AM
#5
Thread Starter
Addicted Member
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-
-
Oct 29th, 2002, 04:04 PM
#6
Thread Starter
Addicted Member
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-
-
Oct 30th, 2002, 12:44 AM
#7
Addicted Member
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
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
|