473,770 Members | 5,569 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(PH OTO.WIDTH*3,PHO TO.HEIGHT)

FILEGET(1,PHOTO .MATRIX(PHOTO.W IDTH*3,PHOTO.HE IGHT),STARTPIXE L)

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,HEIGH T,23)

Some help please!!!

Oct 25 '07 #1
2 2803
On Oct 25, 4:52 pm, "Marco Biagioni" <marco1...@inte rfree.itwrote:
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(PH OTO.WIDTH*3,PHO TO.HEIGHT)

FILEGET(1,PHOTO .MATRIX(PHOTO.W IDTH*3,PHOTO.HE IGHT),STARTPIXE L)

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,HEIGH T,23)

Some help please!!!
Can you give us a complete snipit of code - along with the declaration
of any structures/arrays etc.

--
Tom Shelton

Oct 26 '07 #2
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.pic Photo.Size = size
'.FormPhoto.pic Foto.Background Image =
System.Drawing. Image.FromFile( NomePhoto)

FileOpen(1, PhotoName, OpenMode.Binary )
'UPGRADE_WARNIN G: Get was upgraded to FileGet and has a
new behavior. Click for more:
'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?ke yword="9B7D5ADD-D8FE-4819-A36C-6DEDAF088CC7"'
FileGet(1, pixelOffset, 11)
'UPGRADE_WARNIN G: Get was upgraded to FileGet and has a
new behavior. Click for more:
'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?ke yword="9B7D5ADD-D8FE-4819-A36C-6DEDAF088CC7"'
FileGet(1, w, 19) 'Width
'UPGRADE_WARNIN G: Get was upgraded to FileGet and has a
new behavior. Click for more:
'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?ke yword="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(pixelOf fset - 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,beginni ng read from StartPixel

FileClose(1)

End With
End Sub

Oct 26 '07 #3

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

Similar topics

5
4861
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 System.Drawing.Bitmap from that value? Regards, Steve
11
7484
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
1865
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. The problem is that the DrawString function seems to work only on the desktop and not on the hx4700. Does any body know how to get around the DrawString to draw a string on a bitmap image at runtime?
3
7358
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 crop the image and resize it, but I assume thats straight foward and for the code below Ive set the resize to 0.5 the original size and left the crop out. This is what Ive got so far :-
10
1844
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 .80 .99 I've written code to calculate the correlation data and it is populated in a vector like this:
2
1640
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 database. The default behaviour of loading all the contents of the parent data table and also all the related data is not acceptable, its takes too long to complete. What I need to do IMHO, is to load the parent table and after its loaded, and it gets...
5
2570
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, I want to add a button. When user click on it, I want the bitmap shift to the left by 10% and fill the new area with new information requested. Here is the code I have in the button handler: if (bitmap == null) return; Graphics graphics =...
2
1739
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 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:
6
3776
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 = 1 To 1300 For j = 1 To 1000 Sgl = Matrix(i, j) color = CInt(255 * (Sgl - SglMin) / (SglMax - SglMin))
0
9592
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9425
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10059
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10005
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8887
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6679
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5313
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5452
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2817
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.