This is probably just a stupid mistake, but I can't get SDL_GetRGBA to work:

Code:
var theimage : PSDL_Surface;
  pixel : Uint32;
  fmt : PSDL_PixelFormat;
  r, g, b, a : PUint8;
[...]
  theimage := IMG_Load('test.png');
  fmt := theimage^.format;
  pixel := SDL_GetPixel(theimage, y, x);
  SDL_GetRGBA(pixel, fmt, r, g, b, a);
Whenever it gets to the SDL_GetRGBA call, the program just closes. If I comment out this line, everything's fine. Am I declaring my variables incorrectly?