SDL_BlitSurface

Use this function to perform a fast surface copy to a destination surface.

Syntax

Toggle line numbers

int SDL_BlitSurface(SDL_Surface*    src,
const SDL_Rect* srcrect,
SDL_Surface* dst,
SDL_Rect* dstrect)

Function Parameters

src

the SDL_Surface structure to be copied from

srcrect

the SDL_Rect structure representing the rectangle to be copied, or NULL to copy the entire surface

dst

the SDL_Surface structure that is the blit target

dstrect

the SDL_Rect structure representing the rectangle that is copied into

Return Value

Returns 0 if the blit is successful or a negative error code on failure; call SDL_GetError() for more information.

Code Examples

Toggle line numbers

You can add your code example here

Remarks

You should call SDL_BlitSurface() unless you know exactly how SDL blitting works internally and how to use the other blit functions.

This is the public blit function, and it performs rectangle validation and clipping before passing it to SDL_LowerBlit().

The blit function should not be called on a locked surface.

The width and height in srcrect determine the size of the copied rectangle. Only the position is used in the dstrect (the width and height are ignored). Blits with negative dstrectcoordinates will be clipped properly.

If srcrect is NULL, the entire surface is copied. If dstrect is NULL, then the destination position (upper left corner) is (0, 0).

The final blit rectangle is saved in dstrect after all clipping is performed (srcrect is not modified).

The blit semantics for surfaces with and without blending and colorkey are defined as follows:

  • RGBA->RGB:

    • Source surface blend mode set to SDL_BLENDMODE_BLEND:

      • alpha-blend (using the source alpha-channel and per-surface alpha) SDL_SRCCOLORKEY ignored.

      Source surface blend mode set to SDL_BLENDMODE_NONE:

      • copy RGB. if SDL_SRCCOLORKEY set, only copy the pixels matching the RGB values of the source color key, ignoring alpha in the comparison.

    RGB->RGBA:

    • Source surface blend mode set to SDL_BLENDMODE_BLEND:

      • alpha-blend (using the source per-surface alpha)

      Source surface blend mode set to SDL_BLENDMODE_NONE:

      • copy RGB, set destination alpha to source per-surface alpha value.

      both:

      • if SDL_SRCCOLORKEY set, only copy the pixels matching the source color key.

    RGBA->RGBA:

    • Source surface blend mode set to SDL_BLENDMODE_BLEND:

      • alpha-blend (using the source alpha-channel and per-surface alpha) SDL_SRCCOLORKEY ignored.

      Source surface blend mode set to SDL_BLENDMODE_NONE:

      • copy all of RGBA to the destination. if SDL_SRCCOLORKEY set, only copy the pixels matching the RGB values of the source color key, ignoring alpha in the comparison.

    RGB->RGB:

    • Source surface blend mode set to SDL_BLENDMODE_BLEND:

      • alpha-blend (using the source per-surface alpha)

      Source surface blend mode set to SDL_BLENDMODE_NONE:

      • copy RGB.

      both:

      • if SDL_SRCCOLORKEY set, only copy the pixels matching the source color key.

Related Functions

SDL_BlitSurface的更多相关文章

  1. SDL第一个程序:加载一张图片

    直接看代码吧 using System; using System.Collections.Generic; using System.ComponentModel; using System.Dat ...

  2. SDL文字和图形

    SDL本身没有显示文字功能,它需要用扩展库SDL_ttf来显示文字.ttf是True Type Font的缩写,ttf是Windows下的缺省字体,它有美观,放大缩小不变形的优点,因此广泛应用很多场合 ...

  3. SDL制作拼图游戏

    看完教程第三集后,好像自己能用这个来写一个简单的拼图游戏,第一次写出个带界面的游戏,好有成就感. 图片是自己慢慢截左上部分8个脸. #include <stdio.h> #include ...

  4. SDL教程第一和第二个视频的笔记

    观看正月点灯笼的SDL教程,地址http://www.tudou.com/listplay/9eG9tkk91oQ.html #include <stdio.h> #include < ...

  5. SDL1.2学习

    http://wenku.baidu.com/view/c953c0878762caaedd33d4d8.html 一.安装: sudo apt-get install libsdl1.2-dev l ...

  6. 转:SDL2源代码分析

    1:初始化(SDL_Init()) SDL简介 有关SDL的简介在<最简单的视音频播放示例7:SDL2播放RGB/YUV>以及<最简单的视音频播放示例9:SDL2播放PCM>中 ...

  7. SDL1.2到2.0的迁移指南(转)

    里面有些单词不好翻译所以放在开头,以备查验. BLock Image Transfer, a computer graphics operation in which two bitmap patte ...

  8. DLL——SDL_PingGe

    这篇随笔专门做SDL的DLL开发. 下面这个版本暂且称为Beta版本吧. /* typedef void (*FUNCTION)(void); HMODULE HDll; HDll = LoadLib ...

  9. SDL_PingGe 1.2

    加入了像素填充函数,必须要在一个指定颜色的边界范围内,边界必须没有缺口. 加入了鼠标类 /* typedef void (*FUNCTION)(void); HMODULE HDll; HDll = ...

随机推荐

  1. 懒人小工具1:winform自动生成Model,Insert,Select,Delete以及导出Excel的方法

       懒人小工具2:T4自动生成Model,Insert,Select,Delete以及导出Excel的方法    github地址:https://github.com/Jimmey-Jiang/J ...

  2. 有道云笔记导入txt文件的方法

    有道云笔记pc版迷之不能导入txt文件 尝试很多方法后发现 通过网页版 有道云 可以直接上传 但是pc版不能查看而移动端可以查看 很迷~

  3. HDU-6440-费马小定理

    亏我前几天还学数论呢...没有深入研究费马小定理这个东西...做事情一定要静下心来啊... 题目要求满足(m+n)^p=m^p+n^p,要你定义一个封闭的新的加法和乘法运算 我们知道费马小定理中有两种 ...

  4. Codeforces Round #504 (rated, Div. 1 + Div. 2, based on VK Cup 2018 Final)-A-Single Wildcard Pattern Matching

    #include<iostream> #include<algorithm> #include<stdio.h> #include<string.h> ...

  5. linux及安全第三周总结——跟踪分析LINUX内核的启动过程

    linux内核目录结构 arch目录包括了所有和体系结构相关的核心代码.它下面的每一个子目录都代表一种Linux支持的体系结构,例如i386就是Intel CPU及与之相兼容体系结构的子目录.PC机一 ...

  6. 第六次作业-my Backlog

    杨灵超小组 My  Backlog                                小学生四则运算自动生成(Backlog) ID Name IMP EST How   to Demo ...

  7. HDOJ4548_美素数

    简单的素数问题 HDOJ4548_美素数 #include<stdio.h> #include<stdlib.h> #include<math.h> #includ ...

  8. 【转】C语言宏高级用法 [总结]

    1.前言  今天看代码时候,遇到一些宏,之前没有见过,感觉挺新鲜.如是上网google一下,顺便总结一下,方便以后学习和运用.C语言程序中广泛的使用宏定义,采用关键字define进行定义,宏只是一种简 ...

  9. opencv学习笔记(四)

    ROI---设定感兴趣的区域(region of interest) 定义: Mat imageROI; //方法一:通过Rect指定矩形区域 imageROI=image(Rect(500,250, ...

  10. 『编程题全队』Beta 阶段冲刺博客三

    1.提供当天站立式会议照片一张 2.每个人的工作 (有work item 的ID) (1) 昨天已完成的工作 孙志威: 1.添加登录框的功能 2.修改登录框的UI 孙慧君: 1.提醒显示UI设计: 2 ...