Results 1 to 7 of 7

Thread: SDL2 Help geting rgb colors

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #4
    I can't test this code, but it seems something like:

    Code:
    function getpixel(surface: SDL_Surface; num: integer): cardinal;
    var bpp: integer;
         p: PByte;
    begin
        bpp := surface.format.BytesPerPixel;
        p := pointer(surface.pixels + num * bpp); 
        case bpp of
          1: result := p^;
          2: result := PWord(p)^;
          3: begin
            if (SDL_BYTEORDER = SDL_BIG_ENDIAN)
                result := p[0] shl 16 or p[1] shl 8 or p[2]
            else
                result := p[0] or p[1] shl 8 or p[2] shl 16;
          end;
          4: result := PCardinal(p)^;
          default: result := 0;
        end;
    end;
    edit: If you have the pixel, you can try this function
    http://www.libsdl.org/release/SDL-1....sdlgetrgb.html
    or
    http://www.libsdl.org/release/SDL-1....dlgetrgba.html
    Last edited by User137; 10-01-2015 at 11:08 AM.

Tags for this Thread

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
  •