nigelcct
asked on
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?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I have a small sample with pure VB code, if you want...
ASKER
Thank for your help..
wonder you know how to form a Bitmap??
wonder you know how to form a Bitmap??
I'll give you a complete sample if you reject the small MikeP answer. (i mean small for the answer !)
ASKER
Yes please.. Can I have it?? can you email me
nigelcct@singnet.com.sg
Thanks
nigelcct@singnet.com.sg
Thanks
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
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
In the code, your can remove this line to view the picture...
Picture1.Visible = False
Picture1.Visible = False