Advertisement
Guest User

Untitled

a guest
Aug 27th, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. /**
  2. * Method that create the images related to the difficulty of a recepy
  3. * @param context
  4. * @param difficulty that represent the number of chef_hat_ok into the final image
  5. * @return a Bitmap representing the difficult of a recepy
  6. */
  7. public static Bitmap createRankingImg(Context context, int difficulty) {
  8.  
  9. // Create a Bitmap image starting from the star.png into the "/res/drawable/" directory:
  10. Bitmap myBitmap = BitmapFactory.decodeResource(context.getResources(), R.drawable.chef_hat_ok_resize);
  11.  
  12.  
  13. // Create a new image bitmap having width to hold 5 star.png image:
  14. Bitmap tempBitmap = Bitmap.createBitmap(myBitmap.getWidth() * 5, myBitmap.getHeight(), Bitmap.Config.RGB_565);
  15.  
  16. Canvas tempCanvas = new Canvas(tempBitmap);
  17.  
  18. // Draw the image bitmap into the cavas:
  19. tempCanvas.drawBitmap(myBitmap, 0, 0, null);
  20. tempCanvas.drawBitmap(myBitmap, myBitmap.getWidth(), 0, null);
  21. tempCanvas.drawBitmap(myBitmap, myBitmap.getWidth() * 2, 0, null);
  22. tempCanvas.drawBitmap(myBitmap, myBitmap.getWidth() * 3, 0, null);
  23. tempCanvas.drawBitmap(myBitmap, myBitmap.getWidth() * 4, 0, null);
  24.  
  25.  
  26. return tempBitmap;
  27.  
  28. }
  29.  
  30. difficultyContainerImageView1.setImageDrawable(new BitmapDrawable(getResources(), ImgUtility.createRankingImg(context, 3)));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement