473,790 Members | 2,481 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Picturedata to image

11 New Member
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
Expand|Select|Wrap|Line Numbers
  1. Function FPictureDataToClipBoard(ctl As Variant) As Boolean
  2. ' Memory Vars
  3. Dim hGlobalMemory As Long
  4. Dim lpGlobalMemory As Long
  5. Dim hClipMemory As Long
  6.  
  7. ' Cf_metafilepict structure
  8. Dim cfm As METAFILEPICT
  9.  
  10. ' Handle to a Memory Metafile
  11. Dim hMetafile As Long
  12.  
  13. ' Which ClipBoard format is contained in the PictureData prop
  14. Dim CBFormat As Long
  15.  
  16. ' Byte array to hold the PictureData prop
  17. Dim bArray() As Byte
  18.  
  19. ' Temp var
  20. Dim lngRet As Long
  21.  
  22. On Error GoTo Err_PtoC
  23.  
  24. ' Resize to hold entire PictureData prop
  25. ReDim bArray(LenB(ctl) - 1)
  26.  
  27. ' Copy to our array
  28. bArray = ctl
  29.  
  30. ' Determine which ClipBoard format we are using
  31. Select Case bArray(0)
  32.  
  33.  
  34. Case 40
  35. ' This is a straight DIB.
  36. CBFormat = CF_DIB
  37. ' MSDN states to Allocate moveable|Shared Global memory
  38. ' for ClipBoard operations.
  39. hGlobalMemory = GlobalAlloc(GMEM_MOVEABLE Or GMEM_SHARE Or GMEM_ZEROINIT, UBound(bArray) + 1)
  40. If hGlobalMemory = 0 Then _
  41. Err.Raise vbObjectError + 515, "ImageToClipBoard.modImageToClipBoard", _
  42.    "GlobalAlloc Failed..not enough memory"
  43.  
  44. ' Lock this block to get a pointer we can use to this memory.
  45. lpGlobalMemory = GlobalLock(hGlobalMemory)
  46. If lpGlobalMemory = 0 Then _
  47. Err.Raise vbObjectError + 516, "ImageToClipBoard.modImageToClipBoard", _
  48.    "GlobalLock Failed"
  49.  
  50. ' Copy DIB as is in its entirety
  51. apiCopyMemory ByVal lpGlobalMemory, bArray(0), UBound(bArray) + 1
  52.  
  53. ' Unlock the memory in preparation to copy to the clipboard
  54. If GlobalUnlock(hGlobalMemory) <> 0 Then _
  55. Err.Raise vbObjectError + 517, "ImageToClipBoard.modImageToClipBoard", _
  56.    "GlobalUnLock Failed"
  57.  
  58.  
  59. Case CF_ENHMETAFILE
  60. ' New Enhanced Metafile(EMF)
  61. CBFormat = CF_ENHMETAFILE
  62. ' Create a Memory based Metafile we can pass to the ClipBoard
  63. hMetafile = SetEnhMetaFileBits(UBound(bArray) + 1 - 8, bArray(8))
  64.  
  65.  
  66. Case CF_METAFILEPICT
  67. ' Old Metafile format(WMF)
  68. CBFormat = CF_METAFILEPICT
  69. ' Create a Memory based Metafile we can pass to the ClipBoard
  70. ' We need to convert from the older WMF to the new EMF format
  71. ' Copy the Metafile Header over to our Local Structure
  72. apiCopyMemory cfm, bArray(8), Len(cfm)
  73. ' By converting the older WMF to EMF this
  74. ' allows us to have a single solution for Metafiles.
  75. ' 24 is the number of bytes in the sum of the
  76. ' METAFILEPICT structure and the 8 byte ClipBoard Format struct.
  77. hMetafile = SetWinMetaFileBits(UBound(bArray) + 24 + 1 - 8, bArray(24), 0&, cfm)
  78.  
  79.  
  80. Case Else
  81. 'Should not happen
  82. Err.Raise vbObjectError + 514, "ImageToClipBoard.modImageToClipBoard", _
  83.    "Unrecognized PictureData ClipBoard format"
  84.  
  85. End Select
  86.  
  87.  ' Can we open the ClipBoard.
  88. If OpenClipboard(0&) = 0 Then _
  89. Err.Raise vbObjectError + 518, "ImageToClipBoard.modImageToClipBoard", _
  90. "OpenClipBoard Failed"
  91.  
  92. ' Always empty the ClipBoard First. Not the friendliest thing
  93. ' to do if you have several programs interacting!
  94. Call EmptyClipboard
  95.  
  96. ' Now set the Image to the ClipBoard
  97. If CBFormat = CF_ENHMETAFILE Or CBFormat = CF_METAFILEPICT Then
  98.  
  99.     ' Remember we can use this logic for both types of Metafiles
  100.     ' because we converted the older WMF to the newer EMF.
  101.     hClipMemory = SetClipboardData(CF_ENHMETAFILE, hMetafile)
  102.  
  103. Else
  104. ' We are dealing with a standard DIB.
  105. hClipMemory = SetClipboardData(CBFormat, hGlobalMemory)
  106.  
  107. End If
  108.  
  109. If hClipMemory = 0 Then _
  110.     Err.Raise vbObjectError + 519, "ImageToClipBoard.modImageToClipBoard", _
  111.     "SetClipBoardData Failed"
  112.  
  113. ' Close the ClipBoard
  114. lngRet = CloseClipboard
  115. If lngRet = 0 Then _
  116.     Err.Raise vbObjectError + 520, "ImageToClipBoard.modImageToClipBoard", _
  117.     "CloseClipBoard Failed"
  118.  
  119.   ' Signal Success!
  120. FPictureDataToClipBoard = True
  121.  
  122.  
  123. Exit_PtoC:
  124. Exit Function
  125.  
  126.  
  127. Err_PtoC:
  128. FPictureDataToClipBoard = False
  129. MsgBox Err.Description, vbOKOnly, Err.Source & ":" & Err.Number
  130. Resume Exit_PtoC
  131.  
  132. 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
Oct 22 '09 #1
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.
Oct 30 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
14444
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".
2
24228
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.
15
31813
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
7
11641
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
15
5367
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...
0
1680
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
2
20910
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. -----------------------------------------------------------------------------
5
4237
by: Dominic Vella | last post by:
Does anyone have any details on what the PictureData structure looks like? Thanks in advance. Dominic
0
10785
Debadatta Mishra
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...
0
9666
marktang
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...
0
10413
Oralloy
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...
0
10200
jinu1996
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...
1
10145
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,...
1
7530
isladogs
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...
0
6769
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();...
1
4094
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
2
3707
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2909
bsmnconsultancy
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.