Board index » delphi » loading and displaying .pck gfx files in Delphi

loading and displaying .pck gfx files in Delphi

Hi Im trying to write an Editor for the aging X-com series of games.

I would be really grateful if someone could explain to me how I can Open the
.pck image files and display them using Delphi.

Many thanx

Greg

 

Re:loading and displaying .pck gfx files in Delphi


Quote
greg wrote in message ...
>Hi Im trying to write an Editor for the aging X-com series of games.

>I would be really grateful if someone could explain to me how I can Open
the
>.pck image files and display them using Delphi.

Rather a vague question. It may mean that you don't know
what exactly is in the files, which would be a problem in
any language. Or it may mean that you know how the files are
laid out, but you're not up to speed to write the program.
So read a book/FAQ/tutorial.

Groetjes,
Maarten Wiltink

Re:loading and displaying .pck gfx files in Delphi


Sorry I should've made my self clearer.

I know the file format, well enough of it to be able to decode it into a
buffer. What i cant seem to do is transfer that data into a bitmap with the
correct palette information. Im not too bad with object pascal.

Thanks

Re:loading and displaying .pck gfx files in Delphi


Quote
greg wrote in message ...
>Sorry I should've made my self clearer.

>I know the file format, well enough of it to be able to decode it into a
>buffer. What i cant seem to do is transfer that data into a bitmap with
the
>correct palette information. Im not too bad with object pascal.

Okay. Would that be a memory bitmap or a file? The file format
is quite simple, especially for 24-bits images, and described
in the help files (start at "BITMAPINFOHEADER" I think, and click
around a lot). In-memory stuff is probably harder, as you'd have
to deal with palettes. I'll leave that to other people.

Groetjes,
Maarten Wiltink

Re:loading and displaying .pck gfx files in Delphi


Thanks yeah it is "in memory", the things i dont know are:

1. I can create a bitmap
    mybitmap:=TBitmap.Create;
    how  do I set the dimensions of the bitmap?
2. Once created, is the only way to access the pixels (bytes) through
    mybitmap.Canvas.Pixels[x,x] ?

regards

Greg

Re:loading and displaying .pck gfx files in Delphi


The message <b146tb$fk...@news7.svr.pol.co.uk>
from "greg" <g...@NOSPAMxdev.net> contains these words:

Quote
> Thanks yeah it is "in memory", the things i dont know are:
> 1. I can create a bitmap
>     mybitmap:=TBitmap.Create;
>     how  do I set the dimensions of the bitmap?

Bitmap.width:=800;
Bitmap.Heigth:=600;

Quote
> 2. Once created, is the only way to access the pixels (bytes) through
>     mybitmap.Canvas.Pixels[x,x] ?

You can use Bitmap.Scanline. Scanline give you a pointer to each row of the
bitmap.

Bitmap.Scanline[0] is the first row. You get at each byte in the row like this

Bitmap.Scanline[0][0] to get byte 0.
Bitmap.Scanline[0][1] to get byte 1.
.....

Scanline is not too fast. You can speed thing up by defining a pointer

var Line:pByteArray;

Line:=Bitmap.Scanline[0];

then you can refer to byte using Line

Line[0] to get byte 0
Line[1] to get byte 1
etc.

You need to know the way bytes are arranged in the underlying bitmap.
For pf24bit they are in the order BGR (I think). For most processsing
you deal in groups of 3 so the actual order is not important.

For pf8Bit they are the 8 bit indices into the palette.

For pf4bit each byte is split into 2 to give a pair of palette indices.

For the other pF formats I am not sure.

Incidentally the palette is accessed via Bitmap.palette.Handle You need to
read the win32 docs to see how to make it.

TBitmap deletes the old palette each time you assign a new value to
handle so you do not need to delete palettes.

--
Sincerely,

Andreas Kyriacou
----------------
http://www.andrikkos.co.uk (Imagine! Image Viewer)

Re:loading and displaying .pck gfx files in Delphi


Thanks Andreas, just what I needed :)

Other Threads