SDL_BlitSurface
SDL_BlitSurface
Use this function to perform a fast surface copy to a destination surface.
Contents
Syntax
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
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.
- 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)
- copy RGB, set destination alpha to source per-surface alpha value.
- 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.
- 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)
- copy RGB.
- if SDL_SRCCOLORKEY set, only copy the pixels matching the source color key.
- Source surface blend mode set to SDL_BLENDMODE_BLEND:
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?