SDL Foundation-2, Configuration sdl2_image (CB)

Source: Internet
Author: User
Preface

The purpose of referencing the Sdl2_image plugin is to use images in PNG, GIF and other formats in the project. This configuration is in the "1, Build development environment" on the basis of the. Steps

Download SDL2 image (http://www.libsdl.org/projects/SDL_image/)

Change "i686-w64-mingw32" file name to "Sdl2_image" and copy to C packing directory

Configuring Sdl2image in Codeblocks

Code

#include <stdio.h> #include <stdlib.h> #include <sdl2/sdl.h>//referencing the SDL library #include <sdl2/sdl_image.h
    >//references sdl_image library int main (int argc,char* argv[])//complete Mian function definition {sdl_init (sdl_init_video); sdl_window* window = Sdl_createwindow ("SDL Tutorial1",//Windows title Sdl_windo
                                    wpos_undefined,sdl_windowpos_undefined,//window position 800,600,//window size
    sdl_window_shown//display in windowed mode);
    Sdl_rect Rect;
    Rect.x = 100;

    RECT.Y = 100; sdl_surface* Surface = sdl_getwindowsurface (window);//Get canvas sdl_surface* image = Img_load ("Arror.png");//Use image to load PNG cells Image Sdl_blitsurface (image,null,surface,&rect);//implement to paste the decal onto the canvas sdl_updatewindowsurface (window);//Update Canvas SDL_FR Eesurface (image);//Release decal sdl_freesurface (surface)//release canvas Sdl_delay (3000);//delay 3 seconds sdl_destroywindow (window);//Destroy painting
Cloth Object Sdl_quit ();//Exit SDL
    return 0;
 }
Note

DLL files must be copied to the project directory

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.