Image16: alpha level support

This commit is contained in:
kichikuou
2019-01-06 16:08:20 +09:00
parent f5b328f191
commit e5047dfbdf
3 changed files with 20 additions and 6 deletions
+6 -6
View File
@@ -268,7 +268,7 @@ static int trans_index2pixel(int depth, int i) {
}
/* 16bitCGの ALPHALEVELを指定 */
static WORD *changeImageAlphaLevel(cgdata *cg) {
BYTE *changeImage16AlphaLevel(cgdata *cg) {
WORD *new_pic = malloc(sizeof(WORD) * cg->width * cg->height), *new_pic_;
WORD *pic = (WORD *)cg->pic;
int pixels = cg->width * cg->height;
@@ -279,7 +279,7 @@ static WORD *changeImageAlphaLevel(cgdata *cg) {
*new_pic = RGB_ALPHALEVEL16(*pic, cg->alphalevel);
new_pic++; pic++;
}
return new_pic_;
return (BYTE *)new_pic_;
}
@@ -528,12 +528,12 @@ void image_drawImage8_fromData(agsurface_t *dib, cgdata *cg, int dx, int dy, int
* dibに16bitCGの描画
*/
void image_drawImage16_fromData(agsurface_t *dib, cgdata *cg, int x, int y, int w, int h) {
WORD *pic_save = NULL;
BYTE *pic_save = NULL;
/* set alpha Level */
if (cg->alphalevel != 255) {
pic_save = (WORD *)cg->pic;
cg->pic = (BYTE *)changeImageAlphaLevel(cg);
pic_save = cg->pic;
cg->pic = changeImage16AlphaLevel(cg);
}
if (cg->spritecolor >= 0) {
@@ -544,7 +544,7 @@ void image_drawImage16_fromData(agsurface_t *dib, cgdata *cg, int x, int y, int
if (cg->alphalevel != 255) {
free(cg->pic);
cg->pic = (BYTE *)pic_save;
cg->pic = pic_save;
}
}
+2
View File
@@ -67,5 +67,7 @@ extern void image_trans_pixel_24to24p(agsurface_t *src, agsurface_t *dst);
extern void image_Mosaic(agsurface_t *dib, int sx, int sy, int w, int h, int dx, int dy, int slice);
extern void image_fillRectangleNeg(agsurface_t *dib, int x, int y, int w, int h, int col);
extern BYTE *changeImage16AlphaLevel(cgdata *cg);
#endif /* __IMAGE__ */
+12
View File
@@ -154,6 +154,13 @@ void sdl_drawImage16_fromData(cgdata *cg, int dx, int dy, int w, int h) {
/* draw alpha pixel */
SDL_Surface *s;
SDL_Rect r_src,r_dst;
BYTE *pic_save = NULL;
/* set alpha Level */
if (cg->alphalevel != 255) {
pic_save = cg->pic;
cg->pic = changeImage16AlphaLevel(cg);
}
if (cg->alpha != NULL && cg->spritecolor != -1) {
unsigned short *p_src = (WORD *)(cg->pic + cg->data_offset);
@@ -208,6 +215,11 @@ void sdl_drawImage16_fromData(cgdata *cg, int dx, int dy, int w, int h) {
setRect(r_dst, dx, dy, w, h);
SDL_BlitSurface(s, &r_src, sdl_dib, &r_dst);
SDL_FreeSurface(s);
if (cg->alphalevel != 255) {
free(cg->pic);
cg->pic = pic_save;
}
}
/*