471,078 Members | 801 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,078 software developers and data experts.

DIB - Memorystream

Hi,

I try to make a DragDrop to a Picturebox, to drag images from IE.
But i'm stuck here :
If (e.Data.GetDataPresent("DeviceIndependentBitmap")) Then
PictureBox1.Image =
e.Data.GetData("DeviceIndependentBitmap")
End If

The problem is, that a cannot make this because
e.Data.GetData("DeviceIndependentBitmap") is a memorystream, what can i do
to make a image with this ?

I saw some example on the NET, but they were all in C#.

Thanks in advance
Nov 20 '05 #1
10 4430
Use the System.Drawing.Bitmap class. It has a constructor that accepts a stream object.

--
Regards,
Anand M
VB.NET MVP

http://www.dotnetindia.com
"LoSTMaN" wrote:
Hi,

I try to make a DragDrop to a Picturebox, to drag images from IE.
But i'm stuck here :
If (e.Data.GetDataPresent("DeviceIndependentBitmap")) Then
PictureBox1.Image =
e.Data.GetData("DeviceIndependentBitmap")
End If

The problem is, that a cannot make this because
e.Data.GetData("DeviceIndependentBitmap") is a memorystream, what can i do
to make a image with this ?

I saw some example on the NET, but they were all in C#.

Thanks in advance

Nov 20 '05 #2
Hi Lostman,

It is very simple
dim abyt() as byte 'as the sample bytearray
Dim ms As New IO.MemoryStream(abyt)
Me.PictureBox1.Image = Image.FromStream(ms) ' or any result other image
object

I am intrested in your drag code, may I see it, when not in this newsgroup
than by email.
My email adres is easy to translate I think.

Cor


Nov 20 '05 #3
* "LoSTMaN" <lo*****@cablevision.qc.ca> scripsit:
I try to make a DragDrop to a Picturebox, to drag images from IE.
But i'm stuck here :
If (e.Data.GetDataPresent("DeviceIndependentBitmap")) Then
PictureBox1.Image =
e.Data.GetData("DeviceIndependentBitmap")
End If

The problem is, that a cannot make this because
e.Data.GetData("DeviceIndependentBitmap") is a memorystream, what can i do
to make a image with this ?


Untested (!):

\\\
Me.Picture1.Image = Image.FromStream(TheMemoryStream)
///

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #4
Hi Herfried,

Those nice mountains in .........................echo

:-)

Cor
Nov 20 '05 #5
* "Cor Ligthert" <no**********@planet.nl> scripsit:
Those nice mountains in .........................echo


No, if there is no byte array...

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #6
See the last row in my message, exactly the same

Nov 20 '05 #7
* "Cor Ligthert" <no**********@planet.nl> scripsit:
See the last row in my message, exactly the same


....

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #8
Damn, i'm still stuck at the same place.. ;o)
Everytme i play with memorystream i finish with an error.
So i'm back to the begining, maybe i will go back to Cobol instead of VB
;o)))

Private Overloads Sub PictureBox1_dragdrop(ByVal sender As Object, ByVal e
As System.Windows.Forms.DragEventArgs) Handles PictureBox1.DragDrop
Dim item As Object = CType(e.Data.GetData("DeviceIndependentBitmap"),
System.Object)
If (e.Data.GetDataPresent("DeviceIndependentBitmap")) Then
PictureBox1.Image = e.Data.GetData(DataFormats.Dib)
End If
End Sub
"Cor Ligthert" <no**********@planet.nl> a écrit dans le message de
news:On****************@TK2MSFTNGP09.phx.gbl...
Hi Lostman,

It is very simple
dim abyt() as byte 'as the sample bytearray
Dim ms As New IO.MemoryStream(abyt)
Me.PictureBox1.Image = Image.FromStream(ms) ' or any result other image
object

I am intrested in your drag code, may I see it, when not in this newsgroup
than by email.
My email adres is easy to translate I think.

Cor

Nov 20 '05 #9
* "LoSTMaN" <lo*****@cablevision.qc.ca> scripsit:
Damn, i'm still stuck at the same place.. ;o)
Everytme i play with memorystream i finish with an error.


What error?

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #10
Hi Lostman,

You are talking about a memorystream, however I see no memorystream in your
message.

I do not know your problem direct, but when I translate it than I think it
has to be something like this.
\\\
Private Overloads Sub PictureBox1_dragdrop(ByVal sender As Object, ByVal e
As System.Windows.Forms.DragEventArgs) Handles PictureBox1.DragDrop
Dim abyt As Abyt = Directcaset(e.Data.GetData("DeviceIndependentBitma p"),
Byte())
Dim ms as New IO.MemoryStream(abyt)
PictureBox1.Image = Image.FromStream(ms)
End Sub
///

Casting to an object works always, however is not so usefull. I know that
you can use PIC for more things in Cobol, however presenting a picture is
more dificult in my opinion.

Cor
Damn, i'm still stuck at the same place.. ;o)
Everytme i play with memorystream i finish with an error.
So i'm back to the begining, maybe i will go back to Cobol instead of VB
;o)))

Private Overloads Sub PictureBox1_dragdrop(ByVal sender As Object, ByVal e
As System.Windows.Forms.DragEventArgs) Handles PictureBox1.DragDrop
Dim item As Object = CType(e.Data.GetData("DeviceIndependentBitmap"),
System.Object)
If (e.Data.GetDataPresent("DeviceIndependentBitmap")) Then
PictureBox1.Image = e.Data.GetData(DataFormats.Dib)
End If
End Sub

Nov 20 '05 #11

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Nicolas | last post: by
13 posts views Thread by Don | last post: by
10 posts views Thread by Asaf | last post: by
3 posts views Thread by =?Utf-8?B?UGhpbCBKb2huc29u?= | last post: by
3 posts views Thread by =?Utf-8?B?VmljdG9y?= | last post: by

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.