Click here to Skip to main content
15,917,481 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
GeneralRe: Can't update if database fields is more than 8 Pin
Luc Pattyn27-Feb-10 14:02
sitebuilderLuc Pattyn27-Feb-10 14:02 
GeneralRe: Can't update if database fields is more than 8 Pin
akosidandan27-Feb-10 17:11
akosidandan27-Feb-10 17:11 
GeneralRe: Can't update if database fields is more than 8 Pin
akosidandan27-Feb-10 20:01
akosidandan27-Feb-10 20:01 
Questionneed help with generics - multi key lookup Pin
Kalyan_A27-Feb-10 2:29
professionalKalyan_A27-Feb-10 2:29 
AnswerRe: need help with generics - multi key lookup Pin
Luc Pattyn27-Feb-10 2:36
sitebuilderLuc Pattyn27-Feb-10 2:36 
GeneralRe: need help with generics - multi key lookup Pin
Kalyan_A27-Feb-10 3:23
professionalKalyan_A27-Feb-10 3:23 
AnswerRe: need help with generics - multi key lookup Pin
Luc Pattyn27-Feb-10 4:04
sitebuilderLuc Pattyn27-Feb-10 4:04 
QuestionCreating Bitmap from MemoryStream Pin
xry200626-Feb-10 13:14
xry200626-Feb-10 13:14 
HI to all.
I have a simple question. I'm trying to create a bitmap from a memory stream. The memory stream is filled with a byte array and there isn't image information, only raw pixel data.
Now I'm confusing because the C# sample code I found in internet runs without errors

<br />
private Image GetImage (long position, int size)<br />
{<br />
	string string1;<br />
	byte[] byteArray1;<br />
	Bitmap bitmap1;<br />
	Stream stream1 = ((Stream) null);<br />
	BinaryReader binaryReader1 = ((BinaryReader) null);<br />
	MemoryStream memoryStream1 = ((MemoryStream) null);<br />
	try<br />
	{<br />
		string1 = string.Format ("{0}gallery{1:D2}.enc", Session.RootPath, this.index);<br />
		stream1 = ((Stream) File.OpenRead (string1));<br />
		binaryReader1 = new BinaryReader (stream1, Encoding.ASCII);<br />
		long int64_1 = binaryReader1.BaseStream.Seek (position, SeekOrigin.Begin);<br />
		byteArray1 = binaryReader1.ReadBytes (size);<br />
		this.ColorBalance (byteArray1);<br />
		memoryStream1 = new MemoryStream (byteArray1);<br />
		try<br />
		{<br />
			bitmap1 = new Bitmap (((Stream) memoryStream1));<br />
		}<br />
		catch<br />
		{<br />
			bitmap1 = new Bitmap (64, 64);<br />
		}<br />
	}<br />
	finally<br />
	{<br />
		if (memoryStream1 != null)<br />
		{<br />
			memoryStream1.Close ();<br />
			memoryStream1 = ((MemoryStream) null);<br />
		}<br />
		if (binaryReader1 != null)<br />
		{<br />
			binaryReader1.Close ();<br />
			binaryReader1 = ((BinaryReader) null);<br />
		}<br />
		if (stream1 != null)<br />
		{<br />
			stream1.Close ();<br />
			stream1 = ((Stream) null);<br />
		}<br />
	}<br />
	return bitmap1;<br />
}<br />


while the conversion to VB.Net (2008) written by me raise an exception

<br />
    Private Function _getImage(ByVal _position As Long, ByVal _size As Integer)<br />
        Dim _bmp As New Bitmap(64, 64)<br />
        Try<br />
            Dim _stream As Stream = File.OpenRead(_file)<br />
            Dim _binaryReader As BinaryReader = New BinaryReader(_stream, Encoding.ASCII)<br />
<br />
            Dim _int64 As Long = _binaryReader.BaseStream.Seek(_position, SeekOrigin.Begin)<br />
            Dim _byteArray As Byte() = _binaryReader.ReadBytes(_size)<br />
<br />
            _colorBalance(_byteArray)<br />
            Dim _memoryStream As New MemoryStream(_byteArray)<br />
            _bmp = Bitmap.FromStream(_memoryStream)       '<--- "Invalid data" exception<br />
<br />
            _memoryStream.Close()<br />
            _binaryReader.Close()<br />
            _stream.Close()<br />
        Catch ex As Exception<br />
            MessageBox.Show(ex.Message, "Get Image error", MessageBoxButtons.OK, MessageBoxIcon.Error)<br />
        End Try<br />
        Return _bmp<br />
    End Function<br />


Why the C# code runs and the VB not? Where I'm wrong?

Thanks.
Perry

P.S.: sorry my english, if you can... Sigh | :sigh:
AnswerRe: Creating Bitmap from MemoryStream Pin
The Man from U.N.C.L.E.2-Mar-10 7:15
The Man from U.N.C.L.E.2-Mar-10 7:15 
GeneralRe: Creating Bitmap from MemoryStream Pin
xry20063-Mar-10 1:39
xry20063-Mar-10 1:39 
GeneralRe: Creating Bitmap from MemoryStream Pin
The Man from U.N.C.L.E.3-Mar-10 3:02
The Man from U.N.C.L.E.3-Mar-10 3:02 
QuestionTimer reset Pin
Bob Beaubien26-Feb-10 11:57
Bob Beaubien26-Feb-10 11:57 
Answerclue Pin
Luc Pattyn26-Feb-10 12:23
sitebuilderLuc Pattyn26-Feb-10 12:23 
GeneralRe: clue Pin
Bob Beaubien26-Feb-10 12:34
Bob Beaubien26-Feb-10 12:34 
GeneralRe: clue Pin
Bob Beaubien26-Feb-10 12:40
Bob Beaubien26-Feb-10 12:40 
GeneralRe: clue Pin
Luc Pattyn26-Feb-10 13:13
sitebuilderLuc Pattyn26-Feb-10 13:13 
QuestionCode problem or exceeded array limits? Pin
Hurricane300026-Feb-10 5:15
Hurricane300026-Feb-10 5:15 
AnswerRe: Code problem or exceeded array limits? Pin
Luc Pattyn26-Feb-10 7:09
sitebuilderLuc Pattyn26-Feb-10 7:09 
AnswerRe: Code problem or exceeded array limits? Pin
Gideon Engelberth26-Feb-10 7:56
Gideon Engelberth26-Feb-10 7:56 
GeneralRe: Code problem or exceeded array limits? Pin
Hurricane300026-Feb-10 9:39
Hurricane300026-Feb-10 9:39 
QuestionExit on Keyboard button Pin
Bob Beaubien25-Feb-10 15:54
Bob Beaubien25-Feb-10 15:54 
AnswerRe: Exit on Keyboard button Pin
Dr.Walt Fair, PE25-Feb-10 17:00
professionalDr.Walt Fair, PE25-Feb-10 17:00 
GeneralRe: Exit on Keyboard button Pin
Bob Beaubien25-Feb-10 17:17
Bob Beaubien25-Feb-10 17:17 
QuestionShortcut Keys [solved] Pin
Mehdi Ghiasi24-Feb-10 23:20
Mehdi Ghiasi24-Feb-10 23:20 
AnswerRe: Shortcut Keys Pin
Nuri Ismail24-Feb-10 23:31
Nuri Ismail24-Feb-10 23:31 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.