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. TCP 三次握手原理,你真的理解吗?

    最近,阿里中间件小哥哥蛰剑碰到一个问题——client端连接服务器总是抛异常.在反复定位分析.并查阅各种资料文章搞懂后,他发现没有文章把这两个队列以及怎么观察他们的指标说清楚. 因此,蛰剑写下这篇文章 ...

  2. Android环境准备

    Android环境准备: 1.安装Java环境(自行安装) 2.下载Android SDK包 3.配置系统环境变量 新建ANDROID_HOME 变量值:SDK安装路径(如:D:\android-sd ...

  3. split-brain 脑裂问题(Keepalived)

    脑裂(split-brain)指在一个高可用(HA)系统中,当联系着的两个节点断开联系时,本来为一个整体的系统,分裂为两个独立节点,这时两个节点开始争抢共享资源,结果会导致系统混乱,数据损坏.对于无状 ...

  4. Git学习笔记 第二章

    文件相关操作 修改readme.txt文件,执行 git status 命令查看当前仓库状态 git status 位于分支 master 尚未暂存以备提交的变更: (使用 "git add ...

  5. 剑指offer:复杂链表的复制

    题目描述: 输入一个复杂链表(每个节点中有节点值,以及两个指针,一个指向下一个节点,另一个特殊指针指向任意一个节点),返回结果为复制后复杂链表的head.(注意,输出结果中请不要返回参数中的节点引用, ...

  6. 3-Python3从入门到实战—基础之数据类型(数字-Number)

    Python从入门到实战系列--目录 Python3 中有六个标准的数据类型: Number(数字) String(字符串) List(列表) Tuple(元组) Sets(集合) Dictionar ...

  7. TortoiseSvn/Git的WaterEffect

    https://github.com/TortoiseGit/TortoiseGit/blob/master/src/Utils/MiscUI/WaterEffect.cpp C#的实现: http: ...

  8. [转帖]Linux内核为大规模支持100Gb/s网卡准备好了吗?并没有

    Linux内核为大规模支持100Gb/s网卡准备好了吗?并没有 之前用 千兆的机器 下载速度 一般只能到 50MB 左右 没法更高 万兆的话 可能也就是 200MB左右的速度 很难更高 不知道后续的服 ...

  9. docker 下运行 postgresql 的命令

    postgresql docker下启动的命令 docker run --name pgdata -p : -e POSTGRES_PASSWORD=Test6530 -v /pgdata:/var/ ...

  10. 转《js闭包与内存泄漏》

    首先,能导致内存泄漏的一定是引用类型的变量,比如函数和其他自定义对象.而值类型的变量是不存在内存泄漏的,比如字符串.数字.布尔值等.因为值类型是靠复制来传递的,而引用类型是靠类似c语言中的指针来传递的 ...