Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Method that create the images related to the difficulty of a recepy
- * @param context
- * @param difficulty that represent the number of chef_hat_ok into the final image
- * @return a Bitmap representing the difficult of a recepy
- */
- public static Bitmap createRankingImg(Context context, int difficulty) {
- // Create a Bitmap image starting from the star.png into the "/res/drawable/" directory:
- Bitmap myBitmap = BitmapFactory.decodeResource(context.getResources(), R.drawable.chef_hat_ok_resize);
- // Create a new image bitmap having width to hold 5 star.png image:
- Bitmap tempBitmap = Bitmap.createBitmap(myBitmap.getWidth() * 5, myBitmap.getHeight(), Bitmap.Config.RGB_565);
- Canvas tempCanvas = new Canvas(tempBitmap);
- // Draw the image bitmap into the cavas:
- tempCanvas.drawBitmap(myBitmap, 0, 0, null);
- tempCanvas.drawBitmap(myBitmap, myBitmap.getWidth(), 0, null);
- tempCanvas.drawBitmap(myBitmap, myBitmap.getWidth() * 2, 0, null);
- tempCanvas.drawBitmap(myBitmap, myBitmap.getWidth() * 3, 0, null);
- tempCanvas.drawBitmap(myBitmap, myBitmap.getWidth() * 4, 0, null);
- return tempBitmap;
- }
- difficultyContainerImageView1.setImageDrawable(new BitmapDrawable(getResources(), ImgUtility.createRankingImg(context, 3)));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement