Fixed per-pixel alpha in keyboard themes

This commit is contained in:
pelya
2010-12-21 11:29:25 +00:00
parent 565f159a20
commit 4d16a4dc88
7 changed files with 1265 additions and 1379 deletions

View File

@@ -1,5 +1,5 @@
# The application settings for Android libSDL port
AppSettingVersion=12
AppSettingVersion=16
LibSdlVersion=1.2
AppName="Ballfield"
AppFullName=net.olofson.ballfield
@@ -10,14 +10,17 @@ SdlVideoResize=y
SdlVideoResizeKeepAspect=n
NeedDepthBuffer=n
AppUsesMouse=n
AppNeedsArrowKeys=n
AppNeedsTwoButtonMouse=n
AppNeedsArrowKeys=y
AppNeedsTextInput=y
AppUsesJoystick=n
AppHandlesJoystickSensitivity=n
AppUsesMultitouch=n
NonBlockingSwapBuffers=n
RedefinedKeys="SPACE RETURN"
AppTouchscreenKeyboardKeysAmount=1
AppTouchscreenKeyboardKeysAmountAutoFire=0
AppTouchscreenKeyboardKeysAmount=7
AppTouchscreenKeyboardKeysAmountAutoFire=2
RedefinedKeysScreenKb="SPACE RETURN"
MultiABI=n
AppVersionCode=101
AppVersionName="1.01"
@@ -27,4 +30,5 @@ AppCflags='-O2 -finline-functions'
AppLdflags=''
AppSubdirsBuild=''
AppUseCrystaXToolchain=n
AppCmdline=''
ReadmeText='^'

View File

@@ -1 +1 @@
fheroes2
ballfield

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -18,8 +18,29 @@ main(int argc, char *argv[])
SDL_Surface * src = IMG_Load(argv[1]);
if(!src)
return 1;
SDL_Surface * format1 = SDL_CreateRGBSurface( SDL_SWSURFACE|SDL_SRCALPHA, 1, 1, 16, 0xF800, 0x7C0, 0x3E, 0x1 );
bool perPixeAlpha = false;
if( argc >= 4 )
perPixeAlpha = true;
if( src->format->BitsPerPixel == 32 )
{
for( int i = 0; i < src->h; i++ )
{
for( int ii = 0; ii < src->w; ii++ )
{
Uint32 alpha = (* (Uint32 *) ((Uint8 *)src->pixels + i*src->pitch + ii*4)) & src->format->Amask;
if( src->format->Amask >= 0x000000ff )
alpha /= 0x1000000;
if( alpha > 15 && alpha < 240 )
{
perPixeAlpha = true;
break;
}
}
}
}
printf("Converter: %s BPP %d %dx%d perPixeAlpha %d\n", argv[1], src->format->BitsPerPixel, src->w, src->h, (int)perPixeAlpha);
SDL_Surface * format1 = SDL_CreateRGBSurface( SDL_SWSURFACE|SDL_SRCALPHA, 1, 1, 16, 0xF800, 0x7C0, 0x3E, 0x1 );
if( perPixeAlpha )
format1 = SDL_CreateRGBSurface( SDL_SWSURFACE|SDL_SRCALPHA, 1, 1, 16, 0xF000, 0xF00, 0xF0, 0xF );
if(!format1)
return 1;
@@ -33,13 +54,13 @@ main(int argc, char *argv[])
fwrite( &w, 1, 4, ff );
int h = htonl(dst->h);
fwrite( &h, 1, 4, ff );
int format = htonl(argc <= 3 ? 0 : 1);
int format = htonl(perPixeAlpha ? 1 : 0);
fwrite( &format, 1, 4, ff );
for( int i = 0; i < dst->h; i++ )
{
for( int ii = 0; ii < dst->w; ii++ )
{
if(* (Uint16 *) ((Uint8 *)dst->pixels + i*dst->pitch + ii*2) & 0x1 == 0 && argc <= 3)
if(* (Uint16 *) ((Uint8 *)dst->pixels + i*dst->pitch + ii*2) & 0x1 == 0 && ! perPixeAlpha)
* (Uint16 *) ((Uint8 *)dst->pixels + i*dst->pitch + ii*2) = 0;
fwrite( (Uint8 *)dst->pixels + i*dst->pitch + ii*2, 1, 2, ff );
}

File diff suppressed because it is too large Load Diff