We can assume ARGB surface format when creating cursors (enforced by higher level API)
authorSam Lantinga <slouken@libsdl.org>
Fri, 11 Mar 2011 13:59:52 -0800
changeset 5472 674d45edfaeb
parent 5471 179adad3ae6f
child 5473 5665ccbd6792
We can assume ARGB surface format when creating cursors (enforced by higher level API)
src/video/windows/SDL_windowsmouse.c
--- a/src/video/windows/SDL_windowsmouse.c	Fri Mar 11 13:56:53 2011 -0800
+++ b/src/video/windows/SDL_windowsmouse.c	Fri Mar 11 13:59:52 2011 -0800
@@ -22,6 +22,7 @@
 
 #include "SDL_config.h"
 
+#include "SDL_assert.h"
 #include "SDL_windowsvideo.h"
 
 #include "../../events/SDL_mouse_c.h"
@@ -49,7 +50,6 @@
 WIN_CreateCursor(SDL_Surface * surface, int hot_x, int hot_y)
 {
     SDL_Cursor *cursor;
-    SDL_Surface *cvt;
     HICON hicon;
     HDC hdc;
     BITMAPV4HEADER bmh;
@@ -77,12 +77,9 @@
     ii.hbmMask = CreateBitmap(surface->w, surface->h, 1, 1, NULL);
     ReleaseDC(NULL, hdc);
 
-    cvt = SDL_ConvertSurfaceFormat(surface, SDL_PIXELFORMAT_ARGB8888, 0);
-    if (!cvt) {
-        return NULL;
-    }
-    SDL_memcpy(pixels, cvt->pixels, cvt->h * cvt->pitch);
-    SDL_FreeSurface(cvt);
+    SDL_assert(surface->format->format == SDL_PIXELFORMAT_ARGB8888);
+    SDL_assert(surface->pitch == surface->w * 4);
+    SDL_memcpy(pixels, surface->pixels, surface->h * surface->pitch);
 
     hicon = CreateIconIndirect(&ii);