Bytearray to Image control?

Bytearray to Image control?

Post by Janne Kej » Thu, 03 Jul 2003 14:15:57



I have saved some pictures (jpg) in a database as bytearrays. Now I get them
into an Image control by first getting the bytearray from database, then
persisting it to a temporary file and finally loading the file into the
Image control. This seems inefficient, so I have tried to get the bytearray
to the Clipboard. However, I get either Type mismatch or Object variable not
set -error when I try to do this. How do I convert a bytearray into an image
that Clipboard will understand? Or even better: How do I get the bytearray
directly into the Image control?

Many thanks,

Janne

 
 
 

Bytearray to Image control?

Post by Mike D Sutto » Thu, 03 Jul 2003 18:11:05


Quote:> I have saved some pictures (jpg) in a database as bytearrays. Now I get
them
> into an Image control by first getting the bytearray from database, then
> persisting it to a temporary file and finally loading the file into the
> Image control. This seems inefficient, so I have tried to get the
bytearray
> to the Clipboard. However, I get either Type mismatch or Object variable
not
> set -error when I try to do this. How do I convert a bytearray into an
image
> that Clipboard will understand? Or even better: How do I get the bytearray
> directly into the Image control?

If you're storing the image data as simply the file's bytes then you can use
OLE to display it for you.  For an example of this, have a look at
the"graphicload.zip" demo over on:
http://www.mvps.org/btmtz/_misc/index.htm
If on the other hand you're storing the image data as just the DIB bytes
then you can use SetDIBitsToDevice() to display the image, there's an
example here:
http://groups.google.co.uk/groups?selm=%23k%24rgYcODHA.2316%40TK2MSFT...
Hope this helps,

    Mike

 - Microsoft Visual Basic MVP -

WWW: Http://www.mvps.org/EDais/

 
 
 

Bytearray to Image control?

Post by Janne Kej » Thu, 03 Jul 2003 18:33:52


Thank you, Mike, this works fine!

Janne



Quote:> > I have saved some pictures (jpg) in a database as bytearrays. Now I get
> them
> > into an Image control by first getting the bytearray from database, then
> > persisting it to a temporary file and finally loading the file into the
> > Image control. This seems inefficient, so I have tried to get the
> bytearray
> > to the Clipboard. However, I get either Type mismatch or Object variable
> not
> > set -error when I try to do this. How do I convert a bytearray into an
> image
> > that Clipboard will understand? Or even better: How do I get the
bytearray
> > directly into the Image control?

> If you're storing the image data as simply the file's bytes then you can
use
> OLE to display it for you.  For an example of this, have a look at
> the"graphicload.zip" demo over on:
> http://www.mvps.org/btmtz/_misc/index.htm
> If on the other hand you're storing the image data as just the DIB bytes
> then you can use SetDIBitsToDevice() to display the image, there's an
> example here:

http://groups.google.co.uk/groups?selm=%23k%24rgYcODHA.2316%40TK2MSFT...

- Show quoted text -

> Hope this helps,

>     Mike

>  - Microsoft Visual Basic MVP -

> WWW: Http://www.mvps.org/EDais/

 
 
 

1. Control instance image/picture control.

Hi,
    I have the following problem. I created instance of image control at
run the using

                                            e.g.load  image1(n)

                                            where n = 0,1,2,3,4,etc....

     I want to control the instance of a image control.
Is there  mouse_down event or  mouse_click event,etc events for the
dynamically created
image control.  So that when the dynamically created image control is
clicked, there
is a respond.

Below is my simple code that create instance of image control.

Thanks
Alan.

///////////////////////////////////////////////////////////////////////////////////////////////////////////////

General  Declarations

'n is global and increase as image control increase
Public n As Integer

Private Sub Form_DragDrop(Source As Control, X As Single, Y As Single)

'draging ends
Source.Drag vbEndDrag

'Source.Move X - Source.Width / 2, Y - Source.Height / 2

n  = n +  1

'when drag ends put a new image control indexed by "n" on the form
Load Image1(n )
Image1(n).Left = X - Source.Width / 2
Image1(n).Top = Y - Source.Height / 2
Image1(n).Visible = True

End Sub

Private Sub Form_Load()
'initailize  number of image control = 0
n = 0

End Sub

Private Sub Image1_MouseDown(Index As Integer, Button As Integer, Shift
As Integer, s Single, Y As Single)

' Begin drag
Image1(0).Drag vbBeginDrag
End Sub

2. Equipment upgrade, software, etc...

3. Control new image/picture control

4. Color Postscript Printer Service

5. Write Picture as ByteArray directly to file and load it from there to display it again

6. Can't print to Epson 1270 with Win2000 and PS6

7. stdPicture to ByteArray and back

8. Trouble debugging app which uses SSE2 instructions

9. Creating bytearray for pf1bit bmp?

10. image controls on image viewer?

11. Moving a image by using API without erasing a real image control

12. Color Count of image in an image (or picturebox) control

13. Image stored in a image control needs to appear fainter when disabled