How To Draw A Bitmap

This beginner level how to shows you how a bitmap is drawn to the game window in SwinGame.

howtodrawabitmap

Level

Beginner

Details

There are two main functions you will want to perform with images in SwinGame. SwinGame provides procedures to draw JPEG, PNG or TIFF file. To use an image in your SwinGame project move your file into the Resources/images sub folder. Then call the LoadBitmap function. Once you have loaded your bitmap, you can call DrawBitmap. Don't forget to call RefreshScreen to ensure your bitmap is visible in the game window.

SwinGame offers a number of other functions and procedures when working with images. Explore the Images API for alternate ways of loading and drawing Bitmaps to the game window.


Source Code Widget

  • program HowToDrawABitmap;
    uses SwinGame,sgTypes;
    
    procedure Main();
    
    begin
        OpenGraphicsWindow('Draw Bitmap' ,800 ,600 );
        ClearScreen(ColorWhite );
        LoadBitmapNamed('rocket image' ,'rocket_large.png' );
        DrawBitmap('rocket image' ,111 ,4 );
        RefreshScreen();
        Delay(5000 );
        ReleaseAllResources();
    end;
    begin
        Main();
    end.
    Download Now"
  • #include 
    #include "SwinGame.h"
    int main() 
    {
    
        open_graphics_window("Draw Bitmap" ,800 ,600 );
        clear_screen(color_white );
        load_bitmap_named("rocket image" ,"rocket_large.png" );
        draw_bitmap("rocket image" ,111 ,4 );
        refresh_screen();
        delay(5000 );
        release_all_resources();
        return 0;
    }
    
    Download Now"
  • Source Code Coming Soon

  • Source Code Coming Soon

  • Source Code Coming Soon

Delay and refresh screen procedures can help you draw images at different times.

Possibilities

  • Start by drawing a single picture to the screen
  • Try drawing it multiple times, in different locations
  • Test out drawing different images
  • You can make your own album or a storyboard
  • A slideshow with images and texts
  • Your very own interactive comic book