Application update

M

Marco Biagioni

I'm trying to update my program to manage bitmap file written in vb 6.0

For bmp files accessing i used functions like those...


Open NameBmp For Binary As #1
Get #1, 11, pixelOffset
Get #1, 19, w 'Width
Get #1, 23, h 'Height

declaring

dim w as long
dim h as long
dim pixelOffset as long

How can obtain the same in VB.NET?
I tried with

Dim fs As FileStream = File.Open(NomeBmp, _
FileMode.Open, _
FileAccess.Read, _
FileShare.None)

fs.Read(pixelOffset, 11, 7)
fs.Read(h, 19, 4)
fs.Read(w, 23, 4)

but Read method retrieved an array of Byte and doesn't store the read bytes
in a Long variables as Get statement, so i can't do something like

CalculateMultiple4(w * 3)

How can i do?
 
A

Armin Zingler

Marco Biagioni said:
I'm trying to update my program to manage bitmap file written in vb
6.0

For bmp files accessing i used functions like those...


Open NameBmp For Binary As #1
Get #1, 11, pixelOffset
Get #1, 19, w 'Width
Get #1, 23, h 'Height

declaring

dim w as long
dim h as long
dim pixelOffset as long

How can obtain the same in VB.NET?
I tried with

Dim fs As FileStream = File.Open(NomeBmp, _
FileMode.Open, _
FileAccess.Read, _
FileShare.None)

fs.Read(pixelOffset, 11, 7)
fs.Read(h, 19, 4)
fs.Read(w, 23, 4)

but Read method retrieved an array of Byte and doesn't store the
read bytes in a Long variables as Get statement, so i can't do
something like

CalculateMultiple4(w * 3)

How can i do?

Have you already tried loading the VB6 application in VB.Net? The upgrade
wizard will upgrade the code (AGAP). As you probably know (if not, this is
the first thing you should learn), the Long data type has 64 bits now, and
Integer (equal to Int32) has 32 bits.

You can read directly from the Filestream or you can get help from a
BinaryReader.

dim br as io.binaryreader
br = new io.binaryreader(fs)

fs.seek(11, IO.SeekOrigin.Begin)
pixeloffset = br.readint32



Armin
 
M

Marco Biagioni

Thanks i solved my problem...unfortunatly VB.NET can't convert properly my
old project so i have to rewrite all...but what about the REDIM statement?
It retrieves me an error when i try to use it to resize the dimension of a
matrix...

ReDim Object.g(1 To .w3, 1 To .h)
 
A

Armin Zingler

Marco Biagioni said:
Thanks i solved my problem...unfortunatly VB.NET can't convert
properly my old project

Why? I mean, in order to see how some things get converted, it can be
useful.
so i have to rewrite all...but what about
the REDIM statement? It retrieves me an error when i try to use it
to resize the dimension of a matrix...

ReDim Object.g(1 To .w3, 1 To .h)

The lower bound always must be zero:

ReDim Object.g(0 To .w3 - 1, 0 To .h - 1)

You must review the code that accesses the array because of the new lower
bound.


Armin
 
A

Armin Zingler

Armin Zingler said:
Why? I mean, in order to see how some things get converted, it can
be useful.

To clarify: I didn't mean you should use the wizard to upgrade the project.
I only meant that, even if you rewrite the code, the project upgraded by
the wizard can show the "before - after". Referring to you initial question
it would have shown that Long is Integer now.
ReDim Object.g(0 To .w3 - 1, 0 To .h - 1)

Usually:

ReDim Object.g(.w3 - 1, .h - 1)



Armin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top