As some of you may know, Skywing made a nifty program to read icons. Ok. What I did was use his program to make a new (Blank) bni file which contained the 1 (default) image. In VB, I have been able to parse this correctly. Now to move onto the real bni files. Spht made a legacy icons file (which Skywing's program can parse correctly). All I'm working on is getting the first one out of it, but the code for some reason doesn't work for this file. Here is my code (sure criticize me).
Any help appreciated
Private Sub FRead()
Dim nFreefile As Integer, strData As String
nFreefile = FreeFile
strPath = "C:\Documents and Settings\Admin\Desktop\IconView\legacy_icons.bni"
Open strPath For Binary Access Read As #nFreefile
strData = String(LOF(nFreefile), Chr$(0))
Get #nFreefile, , strData
Close #nFreefile
Debuff.DebuffPacket strData
With Header
.HeaderLength = Debuff.DebuffDWORD
.BNIVersion = Debuff.DebuffWORD
Debuff.RemoveWORD
.NumIcons = Debuff.DebuffDWORD
.DataStart = Debuff.GetDWORD
End With
Debuff.RemoveDWORD
With Info
.Flags = Debuff.DebuffDWORD
.Width = Debuff.DebuffDWORD
.Height = Debuff.DebuffDWORD
.Game = Debuff.DebuffDWORD
End With
With THeader
.InfoLength = Debuff.DebuffBYTE
.ColorMapType = Debuff.DebuffBYTE
.ImageType = Debuff.DebuffBYTE
.ColorMapSpecification = Debuff.DebuffRaw(5)
.XOrigin = Debuff.DebuffWORD
.YOrigin = Debuff.DebuffWORD
.Width = Debuff.DebuffWORD
.Height = Debuff.DebuffWORD
.Depth = Debuff.DebuffBYTE
.Descriptor = Debuff.DebuffBYTE
.NumChars = Debuff.DebuffBYTE
End With
Dim x As Long, y As Long, h As Long
h = Me.hdc
For y = 0 To 13
For x = 0 To 27
TempBlue = Debuff.DebuffBYTE
TempGreen = Debuff.DebuffBYTE
TempRed = Debuff.DebuffBYTE
SetPixel h, x, 13 - y, RGB(TempRed, TempGreen, TempBlue)
Next
Next
End Sub
Quote from: FrostWraith on September 22, 2006, 09:35 PMHere is my code (sure criticize me).
"C:\Documents and Settings\Admin\Desktop\IconView\legacy_icons.bni"
OK! I see two problems. First, you're using VB. Second, you appear to be logged in as an administrator. Both of these are bad ideas. You should not run as an administrator for daily operation of the computer, especially since Microsoft finally got multiple concurrent users somewhat working on a desktop OS with Windows XP (it's still pretty flaky, though). Among other problems, XP seems not to support having one user on the console and another user logged in concurrently on an active RDP session. All that aside, you could use fast user switching to switch to an administrator account on those rare occasions where you need privilege. For normal use, you should use a non-privileged user account.
I'll let someone else lay into you for using VB.
The data is in standerd TGA format you will need to write a decompressor for it before printing the pixels.
Thanks for observing I use VB, and that I'm logged on as an Administator. In fact, there is only one account on this computer (Admin).
Now I will have to look in decompressing the data.
Edit: Can anyone show me an article that helps with decompressing the data.
http://www.google.com/search?client=opera&rls=en&q=TGA+specification&sourceid=opera&ie=utf-8&oe=utf-8
Apparently I have some of the code correct because it can open bni files that only have 1 image inside. But when files with multiple images come around, it fails.
This will fill the icons array which is after the main bni header.
With BHead
.HeadLength = Reader.GetDWORD
.Version = Reader.GetWORD
.Unknowen = Reader.GetWORD
.NumberOfIcons = Reader.GetDWORD
.LocationStart = Reader.GetDWORD
ReDim sIcons(.NumberOfIcons - 1) As ICON_STRUCT 'add a check to be sure the icon count is never '0'.
End With
Dim I As Long
For I = LBound(sIcons) To UBound(sIcons)
With sIcons(I)
.Flags = Reader.GetDWORD
.Width = Reader.GetDWORD
.Height = Reader.GetDWORD
If .Flags = 0 Then
.Icon = Reader.GetStringByLength(4)
If InStr(.Icon, Chr(0)) Then
.Icon = "None"
Else
Reader.GetDWORD
End If
Else
Reader.GetDWORD
End If
End With
Next I