Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Finding the GIF transparency colour through code

Status
Not open for further replies.

RMS001

Programmer
Nov 12, 2002
45
0
0
CA
Hi - Using good old VB6, is it possible to read in a GIF file and decode the header to find out the transparency value. I would then be able to pop it onto a form or user control and set the transparent value of the parent to allow the GIF edges to show through...
 
I'm not sure that I'm with you. VB already knows how to correctly display transparent gifs
 
Hi strongm - I have found a potential solution. The header has byte 7, 8 as width, 9, 10 as height and bytes 14, 15, 16 are the background color:

Private Sub Form_Load()
Dim nFileNum As Integer
nFileNum = FreeFile
Dim iInput(1 To 16) As Byte
Dim sFile As String
sFile = "C:\Data\Image\GIF\starburst.gif"
Open sFile For Binary Access Read Lock Read Write As #nFileNum

Dim i As Integer
For i = 1 To 16
Get #nFileNum, i, iInput(i)
Debug.Print i & vbTab & iInput(i)
Next
Close #nFileNum

lblDimensions(7) = iInput(7)
lblDimensions(8) = iInput(8)
lblDimensions(9) = iInput(9)
lblDimensions(10) = iInput(10)

lblFinal = iInput(7) + iInput(8) * 256 & " x " & iInput(9) + iInput(10) * 256

Shape1.BackColor = RGB(iInput(14), iInput(15), iInput(16))

End Sub

The reason is - I put the gif in the picture and maskpicture properties of a user control, resize it and update the control with the correspondingly resized image. The activeX responds best when the mask colour matches the gif trans color. - Ron

P.S. This is done to get the image to float and overlap over several other pictureboxes etc. which of course the image control won't do.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top