lock unlock
This commit is contained in:
parent
91a46a853f
commit
ed1e26d151
|
@ -593,18 +593,19 @@ img_t gfx_alpha_img(img_t src, int alpha)
|
||||||
if (!img)
|
if (!img)
|
||||||
return NULL;
|
return NULL;
|
||||||
SDL_SetAlpha(img, SDL_SRCALPHA, SDL_ALPHA_OPAQUE);
|
SDL_SetAlpha(img, SDL_SRCALPHA, SDL_ALPHA_OPAQUE);
|
||||||
SDL_LockSurface(img);
|
if (SDL_LockSurface(img) == 0) {
|
||||||
ptr = (Uint32*)img->pixels;
|
ptr = (Uint32*)img->pixels;
|
||||||
size = img->w * img->h;
|
size = img->w * img->h;
|
||||||
while (size --) {
|
while (size --) {
|
||||||
Uint8 r, g, b, a;
|
Uint8 r, g, b, a;
|
||||||
col = *ptr;
|
col = *ptr;
|
||||||
SDL_GetRGBA(col, img->format, &r, &g, &b, &a);
|
SDL_GetRGBA(col, img->format, &r, &g, &b, &a);
|
||||||
col = SDL_MapRGBA(img->format, r, g, b, a * alpha / 255);
|
col = SDL_MapRGBA(img->format, r, g, b, a * alpha / 255);
|
||||||
*ptr = col;
|
*ptr = col;
|
||||||
ptr ++;
|
ptr ++;
|
||||||
|
}
|
||||||
|
SDL_UnlockSurface(img);
|
||||||
}
|
}
|
||||||
SDL_UnlockSurface(img);
|
|
||||||
return img;
|
return img;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue