i have picturedata and i want to save that to image file how i can do that
i have this function but not working for all images - Function FPictureDataToClipBoard(ctl As Variant) As Boolean
-
' Memory Vars
-
Dim hGlobalMemory As Long
-
Dim lpGlobalMemory As Long
-
Dim hClipMemory As Long
-
-
' Cf_metafilepict structure
-
Dim cfm As METAFILEPICT
-
-
' Handle to a Memory Metafile
-
Dim hMetafile As Long
-
-
' Which ClipBoard format is contained in the PictureData prop
-
Dim CBFormat As Long
-
-
' Byte array to hold the PictureData prop
-
Dim bArray() As Byte
-
-
' Temp var
-
Dim lngRet As Long
-
-
On Error GoTo Err_PtoC
-
-
' Resize to hold entire PictureData prop
-
ReDim bArray(LenB(ctl) - 1)
-
-
' Copy to our array
-
bArray = ctl
-
-
' Determine which ClipBoard format we are using
-
Select Case bArray(0)
-
-
-
Case 40
-
' This is a straight DIB.
-
CBFormat = CF_DIB
-
' MSDN states to Allocate moveable|Shared Global memory
-
' for ClipBoard operations.
-
hGlobalMemory = GlobalAlloc(GMEM_MOVEABLE Or GMEM_SHARE Or GMEM_ZEROINIT, UBound(bArray) + 1)
-
If hGlobalMemory = 0 Then _
-
Err.Raise vbObjectError + 515, "ImageToClipBoard.modImageToClipBoard", _
-
"GlobalAlloc Failed..not enough memory"
-
-
' Lock this block to get a pointer we can use to this memory.
-
lpGlobalMemory = GlobalLock(hGlobalMemory)
-
If lpGlobalMemory = 0 Then _
-
Err.Raise vbObjectError + 516, "ImageToClipBoard.modImageToClipBoard", _
-
"GlobalLock Failed"
-
-
' Copy DIB as is in its entirety
-
apiCopyMemory ByVal lpGlobalMemory, bArray(0), UBound(bArray) + 1
-
-
' Unlock the memory in preparation to copy to the clipboard
-
If GlobalUnlock(hGlobalMemory) <> 0 Then _
-
Err.Raise vbObjectError + 517, "ImageToClipBoard.modImageToClipBoard", _
-
"GlobalUnLock Failed"
-
-
-
Case CF_ENHMETAFILE
-
' New Enhanced Metafile(EMF)
-
CBFormat = CF_ENHMETAFILE
-
' Create a Memory based Metafile we can pass to the ClipBoard
-
hMetafile = SetEnhMetaFileBits(UBound(bArray) + 1 - 8, bArray(8))
-
-
-
Case CF_METAFILEPICT
-
' Old Metafile format(WMF)
-
CBFormat = CF_METAFILEPICT
-
' Create a Memory based Metafile we can pass to the ClipBoard
-
' We need to convert from the older WMF to the new EMF format
-
' Copy the Metafile Header over to our Local Structure
-
apiCopyMemory cfm, bArray(8), Len(cfm)
-
' By converting the older WMF to EMF this
-
' allows us to have a single solution for Metafiles.
-
' 24 is the number of bytes in the sum of the
-
' METAFILEPICT structure and the 8 byte ClipBoard Format struct.
-
hMetafile = SetWinMetaFileBits(UBound(bArray) + 24 + 1 - 8, bArray(24), 0&, cfm)
-
-
-
Case Else
-
'Should not happen
-
Err.Raise vbObjectError + 514, "ImageToClipBoard.modImageToClipBoard", _
-
"Unrecognized PictureData ClipBoard format"
-
-
End Select
-
-
' Can we open the ClipBoard.
-
If OpenClipboard(0&) = 0 Then _
-
Err.Raise vbObjectError + 518, "ImageToClipBoard.modImageToClipBoard", _
-
"OpenClipBoard Failed"
-
-
' Always empty the ClipBoard First. Not the friendliest thing
-
' to do if you have several programs interacting!
-
Call EmptyClipboard
-
-
' Now set the Image to the ClipBoard
-
If CBFormat = CF_ENHMETAFILE Or CBFormat = CF_METAFILEPICT Then
-
-
' Remember we can use this logic for both types of Metafiles
-
' because we converted the older WMF to the newer EMF.
-
hClipMemory = SetClipboardData(CF_ENHMETAFILE, hMetafile)
-
-
Else
-
' We are dealing with a standard DIB.
-
hClipMemory = SetClipboardData(CBFormat, hGlobalMemory)
-
-
End If
-
-
If hClipMemory = 0 Then _
-
Err.Raise vbObjectError + 519, "ImageToClipBoard.modImageToClipBoard", _
-
"SetClipBoardData Failed"
-
-
' Close the ClipBoard
-
lngRet = CloseClipboard
-
If lngRet = 0 Then _
-
Err.Raise vbObjectError + 520, "ImageToClipBoard.modImageToClipBoard", _
-
"CloseClipBoard Failed"
-
-
' Signal Success!
-
FPictureDataToClipBoard = True
-
-
-
Exit_PtoC:
-
Exit Function
-
-
-
Err_PtoC:
-
FPictureDataToClipBoard = False
-
MsgBox Err.Description, vbOKOnly, Err.Source & ":" & Err.Number
-
Resume Exit_PtoC
-
-
End Function
i need a function that work for all type of images like embaded on button image ole log how i can do that
1 7387
My friend here you go. This is an unbound object way of doing pictures. http://www.databasedev.co.uk/image-form.html
As far as the buttons go, what you need to do is name the controls in a table based on the names. Reference the names in the table with the controls in the form, while looping through the form controls and find the image associated with the name. I hope i am making sense.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: trojacek |
last post by:
I'm trying to load image data stored in an OLE field into an image
list, that will be used by a treeview to show icons. This is at run
time.
To do this, I'm trying to load the field which...
|
by: deko |
last post by:
I have a table that contains a bunch of pictures. When the user selects a
particular image in a form, I need a way to extract the selected bitmap
image (stored in an OLE Object table field) to the...
|
by: Anand Ganesh |
last post by:
HI All,
I have an Image. I want to clip a portion of it and copy to another image.
How to do this? I know the bounding rectangle to clip.
Any suggestions please.
Thanks for your time and...
|
by: lgbjr |
last post by:
Hello All,
I¡¯m using a context menu associated with some pictureboxes to provide
copy/paste functionality. Copying the image to the clipboard was easy. But
pasting an image from the clipboard...
|
by: David Lozzi |
last post by:
Howdy,
I have a function that uploads an image and that works great. I love ..Nets built in upload, so much easier than 3rd party uploaders!
Now I am making a public function that will take the...
|
by: Frank Schlüter |
last post by:
Hello,
I want to fill an Access-image by an MS-ImageList. The Access-image has
the
properties "picture" and "picturedata". "Picture" is only for load from
File
or BMP, "picturedata" doesn't...
|
by: Dominic Vella |
last post by:
Hi, I know I seem to have the really complicated questions, but I guess
that's why I'm here. This is a little verbose, only because I've been
trying to crack this for a week now.
Your help...
|
by: Dominic Vella |
last post by:
Does anyone have any details on what the PictureData structure looks like?
Thanks in advance.
Dominic
|
by: Debadatta Mishra |
last post by:
Introduction
In this article I will provide you an approach to manipulate an image file. This article gives you an insight into some tricks in java so that you can conceal sensitive information...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
| |