By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
460,045 Members | 1,339 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 460,045 IT Pros & Developers. It's quick & easy.

DIB - Memorystream

P: n/a
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
Share this Question
Share on Google+
10 Replies


P: n/a
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

P: n/a
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

P: n/a
* "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

P: n/a
Hi Herfried,

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

:-)

Cor
Nov 20 '05 #5

P: n/a
* "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

P: n/a
See the last row in my message, exactly the same

Nov 20 '05 #7

P: n/a
* "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

P: n/a
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

P: n/a
* "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

P: n/a
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.