How to form a Bitmap file?

Currently I have keep all the pixel data in an integer array (gray scale 0 to 255(PGM format)).wondering any one teach me how to create a Bitmap image file with the array?
nigelcctAsked:
Who is Participating?
 
MikeP090797Connect With a Mentor Commented:
The easiest way is to put it on a picturebox, and use SavePicture to save it to disk. You can also go to www.wotsit.org, and get the BMP file specifications. You can probobly find some source code as well, but it will be for C
0
 
chabaudCommented:
I have a small sample with pure VB code, if you want...
0
 
nigelcctAuthor Commented:
Thank for your help..
   wonder  you know how to form a Bitmap??
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
chabaudCommented:
I'll give you a complete sample if you reject the small MikeP answer. (i mean small for the answer !)
0
 
nigelcctAuthor Commented:
Yes please.. Can I have it?? can you email me
nigelcct@singnet.com.sg
Thanks
0
 
chabaudCommented:
Create a new form with one picturebox and one commandbutton, and test this:

Option Explicit

Private Sub Form_Load()
    Me.ScaleMode = vbPixels
    Picture1.ScaleMode = vbPixels
End Sub

Private Sub Command1_Click()
    Dim c As Long
    Dim i As Integer
    Dim j As Integer
   
    Picture1.Visible = False
   
    For i = 0 To Picture1.Width
        For j = 0 To Picture1.Height
            'for your pb change next line to: c = YourTab(i,j)
            c = Rnd * 256
            Picture1.PSet (i, j), RGB(c, c, c)
        Next
    Next
   
    SavePicture Picture1.Image, "theFile.bmp"
End Sub

0
 
chabaudCommented:
In the code, your can remove this line to view the picture...
Picture1.Visible = False

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.