Blitting

  1. function SDL_BlitSurface(src : PSDL_Surface; srcrect : PSDL_Rect; dst : PSDL_Surface; dstrect : PSDL_Rect) : integer;

    In the parameters of this vital copying function, src represents source and dst represents destination. PSDL_Rect is a pointer to a rectangle of type TSDL_Rect – a record type defined as follows.

    type
      TSDL_Rect = record 
        x, y : Sint16;  //Position of the upper-left corner of the rectangle
        w, h : Uint16;  // The width and height of the rectangle
      end;
  2. function SDL_SetColorKey(surface : PSDL_Surface; flag, key : UInt32) : integer;

    This function sets the colour key (transparent pixel) in a blittable surface such as a sprite and enables or disables RLE blit acceleration. RLE, which stands for run-length encoding, is used for the compression of images.

    We adapted the following from the help file.

    RLE acceleration can substantially speed up the blitting of images with large horizontal runs of transparent pixels (pixels that match the key value). The key must be of the same pixel format as the surface; SDL_MapRGB is often useful for obtaining an acceptable value.

    If flag is SDL_SRCCOLORKEY then key is the transparent pixel value in the source image of a blit. If flag is OR'd with SDL_RLEACCEL then the surface will be drawn using RLE acceleration when drawn with SDL_BlitSurface. We expect that you will want to pass the flag combination SDL_SRCCOLORKEY OR SDL_RLEACCEL to the function (as we do in our demonstration programs).

  3. function SDL_Flip(screen : PSDL_Surface) : integer;

    Use this function if you are using a 'hardware surface'. The help file states, "On hardware that supports double-buffering, this function sets up a flip and returns. The hardware will wait for vertical retrace, and then swap video buffers." In other words, the function causes the surface that you have been preparing to appear on the screen. See program SDL_ImageDemo1.

  4. procedure SDL_UpdateRect(Display, DstRect.x, DstRect.y,DstRect.h,DstRect.w);

    Use this procedure instead of SDL_Flip to update the window or part of it if you are using a 'software surface'. See program SDL_imageDemo2.

Programming - a skill for life!

Descriptions and demonstrations of SDL procedures and functions