0

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?

arleitiss
  • 1,304
  • 1
  • 14
  • 38

1 Answers1

1

Create a new Bitmap Canvas of the appropriate size and then follow these steps:

  1. Load the lowest Drawable layer as a Bitmap
  2. Create a PorterDuffColorFilter with the user's selected color
  3. Paint the Bitmap to the output Canvas using the filter
  4. 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.

Community
  • 1
  • 1
Kyle Ivey
  • 5,992
  • 1
  • 23
  • 35