summaryrefslogtreecommitdiff
path: root/src/resources/sdlimagehelper.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-07-01 21:57:46 +0300
committerAndrei Karas <akaras@inbox.ru>2014-07-01 21:57:46 +0300
commit62e2ccbb158f146e2c3ceab14ff5581d3f3975ef (patch)
tree736e615b6ff94e09144df7df3aa06f9f231743ff /src/resources/sdlimagehelper.cpp
parentd3b57bd96a07a674432fd28cefd2f20ae5404b8b (diff)
downloadmv-62e2ccbb158f146e2c3ceab14ff5581d3f3975ef.tar.gz
mv-62e2ccbb158f146e2c3ceab14ff5581d3f3975ef.tar.bz2
mv-62e2ccbb158f146e2c3ceab14ff5581d3f3975ef.tar.xz
mv-62e2ccbb158f146e2c3ceab14ff5581d3f3975ef.zip
Add to image helper function to copy surface into part of image.
Diffstat (limited to 'src/resources/sdlimagehelper.cpp')
-rw-r--r--src/resources/sdlimagehelper.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/resources/sdlimagehelper.cpp b/src/resources/sdlimagehelper.cpp
index 7d4090deb..baf1125fa 100644
--- a/src/resources/sdlimagehelper.cpp
+++ b/src/resources/sdlimagehelper.cpp
@@ -284,4 +284,21 @@ int SDLImageHelper::combineSurface(SDL_Surface *restrict const src,
return SDL_gfxBlitRGBA(src, srcrect, dst, dstrect);
}
+void SDLImageHelper::copySurfaceToImage(Image *const image,
+ const int x, const int y,
+ SDL_Surface *const surface) const
+{
+ if (!image || !surface)
+ return;
+
+ SDL_SetAlpha(surface, 0, SDL_ALPHA_OPAQUE);
+ SDL_Rect rect =
+ {
+ x, y,
+ surface->w, surface->h
+ };
+
+ SDL_BlitSurface(surface, nullptr, image->mSDLSurface, &rect);
+}
+
#endif // USE_SDL2