IT博客汇
  • 首页
  • 精华
  • 技术
  • 设计
  • 资讯
  • 扯淡
  • 权利声明
  • 登录 注册

    [原]SDL_SetPalette函数

    caimouse发表于 2016-12-09 13:16:05
    love 0

    SDL_SetPalette函数:

    设置8位表面的调色板。

    定义:

    #include "SDL.h"
    int SDL_SetPalette(SDL_Surface *surface, int flags, SDL_Color *colors, int firstcolor, int ncolors);

    例子:

    /* Create a display surface with a grayscale palette */
            SDL_Surface *screen;
            SDL_Color colors[256];
            int i;
            .
            .
            .
            /* Fill colors with color information */
            for(i=0;i<256;i++){
              colors[i].r=i;
              colors[i].g=i;
              colors[i].b=i;
            }
    
            /* Create display */
            screen=SDL_SetVideoMode(640, 480, 8, SDL_HWPALETTE);
            if(!screen){
              printf("Couldn't set video mode: %s\n", SDL_GetError());
              exit(-1);
            }
    
            /* Set palette */
            SDL_SetPalette(screen, SDL_LOGPAL|SDL_PHYSPAL, colors, 0, 256);
            .
            .
            .
            .


    老蔡学堂


    蔡军生





沪ICP备19023445号-2号
友情链接