Issue
lets say I want to make an app which lets user create avatar from choice of clothes/items and then let other users see these "avatars". So what would be the best way to make this work? I was thinking of having these clothes/items as images, then save user avatars as numbers say: 4f6v31 which would translate into like:
4 = skin color.
f = face.
6 = shirt color.
v = pants color.
3 = shoes.
1 = hair.
Then when user receives say 5 of these "other peoples saved avatars" it would load all 5 avatars by combining those clothes/items images into one drawable. Is such thing possible or is there better way?
Solution
Create a new Bitmap Canvas
of the appropriate size and then follow these steps:
- Load the lowest
Drawable
layer as aBitmap
- Create a
PorterDuffColorFilter
with the user's selected color - Paint the Bitmap to the output Canvas using the filter
- Repeat for the next lowest layer
Once every layer has been painted to the canvas, write it out to a BitmapDrawable
and apply to an ImageView
.
Answered By - Kyle Ivey
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.