Overview |
Description |
Loading the image
A surface is created that loads the targa image
file "image.tga". Note that you can also load an image to a surface any
time you wish like this: "surface.Load("image.tga")". After the image is
loaded it isn't quite ready to be used however, first it is converted to
ARGB8888 pixel format. This is done because PTC only supports fast conversions
from INDEX8, RGB565 and ARGB8888, and the image being loaded is a 24 bit
targa file, so naturally after it is loaded it the surface has a 24 bit
pixel format.
Source code |
int main(int
argc,char *argv[])
{
// initialize from command
line (ie. "image RGB565")
PTC ptc(320,200,argc,argv);
if (!ptc.ok())
{
//
fallback to virtual 32bit
if
(!ptc.Init(320,200))
{
// failure
ptc.Error("could not initialize ptc");
return 1;
}
}
// load image
Surface surface(ptc,"image.tga");
if (!surface.ok())
{
//
failure
ptc.Error("could not
load image");
return
1;
}
// convert image
if (!surface.Convert(ARGB8888))
{
//
failure
ptc.Error("could not
convert image");
return
1;
}
// display image
surface.Update();
ptc.getch();
return 0;
}