473,386 Members | 1,752 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Recover data from a bitmap and filling a matrix

After i've tried to update a vb 6.0 project to vb.net, using visual studio
utility,i can't read correctly data bytes from a .bmp file to insert them in
a matrix to operate on.

Using vb 6.0 the code was based on Get function:

GET #1, PIXELSTART, PHOTO.MATRIX

where PHOTO is a structure data type, with a member MATRIX previously
defined in this way:

ReDim PHOTO.MATRIX(1 TO PHOTO.WIDTH*3,1 TO PHOTO.HEIGHT)

in this way,the program read bytes starting from PIXELSTART in bmp file and
put them in transpose matrix resultant.
For example:
an image of 622*277 pixel has a matrix of 1868*277 bytes considering 24 bit
depth and so 3 bytes per pixel.

With Get function the bidimensional array,the matrix, was filled correctly,
as visible using debugger, with the single pixel value of the bitmap.

Using vb.net, the utility tansformed the code in this way:

ReDim PHOTO.MATRIX(PHOTO.WIDTH*3,PHOTO.HEIGHT)

FILEGET(1,PHOTO.MATRIX(PHOTO.WIDTH*3,PHOTO.HEIGHT) ,STARTPIXEL)

I know the fact that the array in enumerated in different ways in vb 6.0 and
..net(start with 0 in net,with 1 in 6.0), but the big big problem is that THE
MATRIX HERE IS FILLED WITH NOTHING!!!Every matrix value is equal to zero,
and it result in a black image!
The dimensions of the bitmap however are read correctly from bmp file in
this way:

FILEGET(1,WIDTH,19)

FILEGET(1,HEIGHT,23)

Some help please!!!

Oct 25 '07 #1
2 1717
Marco Biagioni wrote:
FILEGET(1,PHOTO.MATRIX(PHOTO.WIDTH*3,PHOTO.HEIGHT) ,STARTPIXEL)
Looking at the help for FileGet, shouldn't that be

FileGet(1, PHOTO.MATRIX)

?

Andrew
Oct 26 '07 #2

in fileget function i must specify dimension of matrix otherwise it gives me
an error...

This is the structure:

Private Structure Photo
Dim PhotoName As String
Dim FormPhoto As frmFoto
Dim w As Integer
Dim w3 As Integer
Dim h As Integer
Dim StartPixel As Integer
Dim header() As Byte
Dim g(,) As Byte 'pixel matrix
End Structure
Then some declarations...

Dim Foto() As Photo
Dim nPhoto As Short

The load routine:

Private Sub LoadPhoto(ByVal PhotoName As String, ByVal Origin As Short)
Dim FormPhoto As Object
'carica Bitmap
Dim w As Integer
Dim h As Integer
Dim pixelOffset As Integer

With Photo(gCurrent)
.FormPhoto = New frmPhoto
.FormPhoto.Text = PhotoName
.FormPhoto.Tag = CStr(gCurrent) ' per associare il form alla foto
corrente
.FormPhoto.Show()
.PhotoName= PhotoName

If Origin = 0 Then ' must read from bmp file

Try
'Dim size As Size =
System.Drawing.Image.FromFile(PhotoName).Size
'.FormPhoto.picPhoto.Size = size
'.FormPhoto.picFoto.BackgroundImage =
System.Drawing.Image.FromFile(NomePhoto)

FileOpen(1, PhotoName, OpenMode.Binary)
'UPGRADE_WARNING: Get was upgraded to FileGet and has a
new behavior. Click for more:
'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="9B7D5ADD-D8FE-4819-A36C-6DEDAF088CC7"'
FileGet(1, pixelOffset, 11)
'UPGRADE_WARNING: Get was upgraded to FileGet and has a
new behavior. Click for more:
'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="9B7D5ADD-D8FE-4819-A36C-6DEDAF088CC7"'
FileGet(1, w, 19) 'Width
'UPGRADE_WARNING: Get was upgraded to FileGet and has a
new behavior. Click for more:
'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="9B7D5ADD-D8FE-4819-A36C-6DEDAF088CC7"'
FileGet(1, h, 23) 'Height
.w = w
.w3 = Multiple4(w * 3) 'width and height are read
correctly
.h = h
.StartPixel = 1 + pixelOffset
ReDim .header(pixelOffset - 1)
"'
FileGet(1, .header, 1)

ReDim .g(.w3, .h) 'transpose matrix
FileGet(1, .g(.w3 - 1, .h - 1), .StartPixel ) 'ERROR
HERE, matrix is filled with nothing,beginning read from StartPixel

FileClose(1)

End With
End Sub

"Andrew Morton" <ak*@in-press.co.uk.invalidha scritto nel messaggio
news:eo**************@TK2MSFTNGP04.phx.gbl...
Marco Biagioni wrote:
>FILEGET(1,PHOTO.MATRIX(PHOTO.WIDTH*3,PHOTO.HEIGHT ),STARTPIXEL)

Looking at the help for FileGet, shouldn't that be

FileGet(1, PHOTO.MATRIX)

?

Andrew
Oct 26 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Steve Amey | last post by:
Hi all I have an ARGB value for a Colour (Eg. -65536. The value was retrieved by using the Color.ToArgb method), is there any way that I can create a System.Drawing.Image or a...
11
by: Prashant | last post by:
Hi, I have a huge problem. I have a data file which looks something like this -: ..1 .5 .9 -1 .2 .5 ...... ..2 .9 .1 .4 .3 -1 ...... ..2 .4 .5 .7 .6 .2 ...... ........
1
by: dcudev.lcr | last post by:
I am loading a 4X5 picturebox matrix using a bitmap file template. As each cell in the matrix is being loaded, I append a text string using the DrawString function to complete the cell's image. ...
3
by: news | last post by:
Hi Guys, Sorry if this is an obvious question but Im trying to rotate a bitmap and then save it. So far Ive only found how to rotates a Graphic but I can't find how to save it. I also want to...
10
by: Nevets Steprock | last post by:
I'm writing a web program where one of the sections is supposed to output a correlation matrix. The typical correlation matrix looks like this: ..23 ..34 .54 ..76 .44 .28 ..02 .77 ...
2
by: Bob | last post by:
I got three related datagrid views one parent and two children of the same. The two child tables contain many thousands of records and some of the contents are bitmap files in a sql server...
5
by: =?Utf-8?B?QVRU?= | last post by:
I have a bitmap of 100X100. On the load, the bitmap is created by a function (createimage()). On my OnPaint, I draw the image back to the screen (e.Graphics.DrawImage( bitmap, destrect)). Now,...
2
by: Marco Biagioni | last post by:
After i've tried to update a vb 6.0 project to vb.net, using visual studio utility,i can't read correctly data bytes from a .bmp file to insert them in a matrix to operate on. Using vb 6.0 the...
6
by: ProtossLee | last post by:
Hi, I am currently working on a project for image processing. a double matrix m1(1300X1000) need to be converted into bitmap and displayed on screen. so far I've made the following code: For i...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

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.