Results 1 to 3 of 3

Thread: TCanvas.Pixels palette entries

  1. #1

    TCanvas.Pixels palette entries

    Seems like a simple question but Canvas.Pixels[X,Y] has been causing me problems. I have loaded an 8 bit bitmap into a TBitmap. It has loaded correctly and the PixelFormat value is showing as pf8Bit. Only problem is, when I go to access the pixels and try to retrieve the palette entry for a particular pixel it is returning the actual colour value for that pixel rather than the palette index that the pixel contains. I need the palette index, not the colour. Any tips?
    Isometric game development blog http://isoenginedev.blogspot.com/

  2. #2

    re-

    Hi,

    Use tbitmap.scanline[row]. which returns a pointer to a complete row of pixels raw data. For 256 color bitmaps each byte in that block memory represet the index color into the pallete for every pixel in that line.


    Btw, this is a old function i have:

    procedure xGetBitmapBits(var bitmap:tbitmap; size:longint; bufointer);

    It gets the whole bitmap into a memory block so i can do faster low level proccesing to the picture. Then i can put back edited pixel info using similar xSetbitmapbits procedure.

    good luck.


    [pascal]
    procedure xGetBitmapBits(var bitmap:tbitmap; size:longint; bufointer);
    var
    pointer;
    bpp:integer;
    lsize:integer;
    y,k:integer;
    buf2:longint;

    begin

    bpp:=2;
    case bitmap.pixelformat of
    pf8bit : bpp:=1;
    pf15bit,pf16bit: bpp:=2;
    pf24bit : bpp:=3;
    pf32bit : bpp:=4;
    end;
    lsize:=bitmap.width*bpp;
    k:=size div lsize; if k=0 then k:=1;
    if lsize>size then lsize:=size;
    buf2:=longint(buf);

    for y:=1 to k do
    begin
    p:=bitmap.scanline[y-1];
    move(p^,pointer(buf2)^,lsize);
    buf2:=buf2+lsize;
    end;


    end;
    //----------------
    [/pascal]

  3. #3

    TCanvas.Pixels palette entries

    Dammit, completely forgot about Scanline. It's been a while. Cheers.
    Isometric game development blog http://isoenginedev.blogspot.com/

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •