Android Question Palette Swap

latch

Active Member
Licensed User
Longtime User
So you can see from my games, I use a buttload of bitmaps:
http://www.b4x.com/android/forum/threads/sup-r-m-troid-wannabe.31185/

I use 90ish bitmaps to animate the dude. One day I will add in the story another exosuit the dude gets and it will be a different color.

Is there a way to alter the palette of a loaded bitmap?

Slightly related, is there way to alter the alpha?

I guess I should add I am using the Accelerated Surface de Informatix
 

latch

Active Member
Licensed User
Longtime User
It looks like AlterColors will work but I don't know how to implement it. I need to be able to draw the altered bitmap in the accelerated surface. Of course, I'm drawing a lot of rocks and so I would want to alter the colors somewhere else and then draw it ten hundred times. I'm getting the immutable error:

B4X:
sub begin
    stone.InitializeMutable(128,128)
    stone = LoadBitmap(File.DirAssets, "images/stoneshadow.png")
end sub

sub surfacedraw

ac.DrawBitmapWithMatrixAt(IU.AlterColors(stone,-1,355,1),(c*128-mx)*scale, (l*128-my)*scale, True)

end sub
 
Upvote 0

latch

Active Member
Licensed User
Longtime User
I had not updated my AC library so it didn't work till I did. I see you got rid of drawrectrotated. What did you replace that with as I was using it extensively and it broke my sparks!
 
Upvote 0

latch

Active Member
Licensed User
Longtime User
I found it- it's a roundabout way:

In this example of rotation, only the rectangle is rotated:
B4X:
AC.SaveState
AC.RotateCanvas(45)
AC.DrawRect(rctRect, Colors.Red, True, 0, True)
AC.RestoreState
AC.DrawOval(rctOval, Colors.Blue, True, 0, True)
 
Upvote 0
Top