Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. @Override
  2. protected void onDraw(Canvas canvas) {
  3. super.onDraw(canvas);
  4. Bitmap bitmap = ((BitmapDrawable)this.getDrawable()).getBitmap();
  5.  
  6. final int w = bitmap.getWidth();
  7. final int h = bitmap.getHeight();
  8. int pixel;
  9. int redValue;
  10. int blueValue;
  11. int greenValue;
  12.  
  13. for (int x = 0; x < w; x++) {
  14. for (int y = 0; y < h; y++) {
  15. pixel = bitmap.getPixel(x, y);
  16. redValue = Color.red(pixel);
  17. blueValue = Color.blue(pixel);
  18. greenValue = Color.green(pixel);
  19. if (redValue == 255 && greenValue == 254 && blueValue == 0){
  20. Paint paint = new Paint();
  21. paint.setColor(Color.BLACK);
  22. paint.setTextSize(35);
  23. canvas.drawText("Some Text", x, y, paint);
  24. }
  25. }
  26. }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement