Sign in to follow this  

tga

This topic is 4834 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

who needs to google around, just take a look at lesson #33, that code only need a few lines of code more and it should work for most tga files.

And I beleve it goes something like this(put this in after it reads the header and before i reads the image data).

if(tgaheader[0])
{
if(fread(&tgaID, tgaheader[0], 1, fTGA) == 0) // Read TGA ID
{
if(fTGA != NULL) // if file is still open
{
fclose(fTGA); // Close it
}
return false; // Return failular
}

}

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Quote:
Original post by lc_overlord
who needs to google around, just take a look at lesson #33, that code only need a few lines of code more and it should work for most tga files.

And I beleve it goes something like this(put this in after it reads the header and before i reads the image data).

if(tgaheader[0])
{
if(fread(&tgaID, tgaheader[0], 1, fTGA) == 0) // Read TGA ID
{
if(fTGA != NULL) // if file is still open
{
fclose(fTGA); // Close it
}
return false; // Return failular
}

}


yes i have read through the tutorial, but stated above, i am using visual basic .net and it is hard to convert that code.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
i am using vb .net because i know almost no C or C++ code. i know most vb .net programmers use directx, but i have never really liked any of directx. OpenGL is faster and has better quality. Anyway i found a control wich allows me to call OpenGL from vb .net (the CsGL control). I am looking at the tutorial now and trying to convert it, but the syntax of structures and arrays are very different.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
i am sorry this seems to be more than i wanted. i just expected a simple yes or no answer as to if there is an easy way to load tga's

Share this post


Link to post
Share on other sites
Quote:
Original post by Anonymous Poster
i am sorry this seems to be more than i wanted. i just expected a simple yes or no answer as to if there is an easy way to load tga's


i'd say the answer is yes, and the code looks like the following. as for porting to vb, i think you'd only need to replace the fread method to be whatever method vb calls to read files. i think everything else should basically be the same (granted i don't know vb):


//repost from above

if(tgaheader[0])
{
if(fread(&tgaID, tgaheader[0], 1, fTGA) == 0) // Read TGA ID
{
if(fTGA != NULL) // if file is still open
{
fclose(fTGA); // Close it
}
return false; // Return failular
}

Share this post


Link to post
Share on other sites
here is what i have so far, does it look like i am on the right track? The reading i think should be easy, it was the structures and things i was confused on.


Public Class tga
Structure headerinfo
Dim header() As Byte
End Structure
Structure Texturest
Dim imageData As Byte
Dim bpp As Integer
Dim width As Integer
Dim height As Integer
Dim texid As Integer
Dim type As Integer
End Structure
Structure TGA
Dim header() As Byte
Dim bytesperpixel As Integer
Dim imagesize As Integer
Dim imageheight As Integer
Dim imagewidth As Integer
Dim type As Integer
Dim bpp As Integer
End Structure
Public Function loadTga(ByVal TexStruc As Texturest, ByVal Path As String)
Dim MyFile As IO.FileInfo = New IO.FileInfo(Path)
Dim reader As IO.Stream
Dim myheader As headerinfo = New headerinfo
If MyFile.Exists Then
reader = MyFile.OpenRead
If reader.CanRead Then
reader.Read(myheader.header, 0, 12)
End If
End If
End Function
End Class

Share this post


Link to post
Share on other sites

This topic is 4834 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this