Image control from Database in VB6
I have some images stored in a database and I want to populate an image control. All the examples I can find copy the image to the hdd and then use loadpicture to开发者_运维知识库 put it in the image control. Is there a way to push the image directly in without going to the hdd first?
Here's some sample code that should get you there fairly easily:
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=29004&lngWId=1
This assumes you have the image in a byte array. You can use standard DB functions to get your image out and into a byte array.
If the database holds the image in typical serialized form (as it would exist in a file) then you can use WIA 2.0 to load the retrieved Byte array and produce a StdPicture object you can assign to the Image control's Picture property.
Windows® Image Acquisition Automation Library v2.0 Tool: Image acquisition and manipulation component for VB and scripting
This can handle PNG and TIFF as well as the usual suspects (GIF, JPEG, BMP).
精彩评论