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 7584 maxamis4 295
Recognized Expert Contributor
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 contains the picturedata
into my image list by using a function that converts the picturedata
into what I believe is a stdpicture.
The Access errors out with "invalid picture".
|
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 file system so the user
can do stuff with "somePicture.bmp", for example.
Is there an easy way to do this?
Thanks in advance.
|
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 help.
Regards
|
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 is proving to be more difficult. These
pictureboxes are bound to an AccessDB. If the user wants to add an image,
they select an image using an OpenFileDialog:
Dim result As DialogResult = Pic_Sel.ShowDialog()
If (result = DialogResult.OK) Then
|
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 path of the uploaded image, and resize it with the provided dimensions. My function is below. The current function is returning an error when run from the upload function: A generic error occurred in GDI+. Not sure what exactly that means. From what...
| |
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 work.
I would use other controls but the Access-Image is the only one (i
have) which could be really in background, so that other textboxes are
|
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 would be appreciated.
I've been trying numerous ways to resize images, as I want to make store
thumbnails, not full images in my database.
-----------------------------------------------------------------------------
|
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 inside an image, hide your complete image as text ,search for a particular image inside a directory, minimize the size of the image. However this is not a new concept, there is a concept called Steganography which enables to conceal your secret...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |