- Home
·
- Graphics
·
- Simply Code To Load 24-Bit uncompressed TGA Files in a PictureBox
Simply Code To Load 24-Bit uncompressed TGA Files in a PictureBox
Simply Code To Load 24-Bit uncompressed TGA Files in a PictureBox
Rate Simply Code To Load 24-Bit uncompressed TGA Files in a PictureBox
(1(1 Vote))
Private Sub Command1_Click()
' Nice Small Code For Loading Uncompressed TGA 24-Bit TGA Files
' The Goal of this Code was to load a 24-Bit TGA file Useing very little Code & Memory
' This Code Only Works with 24 Bit TGA Files
' To use this code Create An App & create a picture box/cmdbutton
' Be sure to change the forms and the picture boxs scalewidth to Pixels
' And Drop code In
'
' Kevin Fowlks Oct 31,2000 [email protected]
Dim r As Byte
Dim g As Byte
Dim b As Byte
Dim w%, h%, c%
Dim imgw As Integer, imgH As Integer
Picture1.DrawWidth = 1
Open "c:\test.tga" For Binary As #1
'Get Image Height & Width from file
Get #1, 13, imgw
Get #1, 15, imgH
' Add 5 so we can see the whole image in the Picture Box
Picture1.Visible = False
Picture1.Width = imgw + 5
Picture1.Height = imgH + 5
Picture1.Move (Form1.ScaleWidth - Picture1.ScaleWidth) / 2, (Form1.ScaleHeight - Picture1.ScaleHeight) / 2
Seek #1, 20 ' Skip Header
For h = imgH - 1 To 0 Step -1
For w = 0 To imgw - 1 Step 1
Get #1, , g ' This is the correct Order for a TGA File
Get #1, , r
Get #1, , b
Picture1.PSet (w, h), RGB(r, g, b)
Next
' DoEvents Only needed if files will be extreamly large
Next
Picture1.Visible = True
Close #1
End Sub
Private Sub Form_Load()
Picture1.Visible = False
End Sub
Simply Code To Load 24-Bit uncompressed TGA Files in a PictureBox Comments
No comments yet — be the first to post one!
Post a Comment