Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.47 KB | None | 0 0
  1. int x1=0;
  2. int y1=0;
  3. boolean res = false;
  4. System.out.println("in formatImage");
  5.  
  6. for (int x = 0; x <= w-1; x++) {
  7. for (int y = 0; y <= h-1; y++) {
  8. if(new Color(bi1.getRGB(x, y)).getRGB()==-1)
  9. {res=false;}
  10. else if (!new Color(bi1.getRGB(x, y)).equals(Color.WHITE)) {
  11. res = true;
  12. }
  13. if (res) {
  14. for (int p = y; p <= h-1; p++) {
  15. b21.setRGB(x1,p,new Color(bi1.getRGB(x, p)).getRGB());
  16. }
  17. x1++;
  18. res = false;
  19. break;
  20. }
  21. }
  22. }
  23. b21=new BufferedImage(x1,h,BufferedImage.TYPE_INT_RGB);
  24. x1=0;
  25. for (int x = 0; x <= w-1; x++) {
  26. for (int y = 0; y <= h-1; y++) {
  27. if(new Color(bi1.getRGB(x, y)).getRGB()==-1)
  28. {res=false;}
  29. else if (!new Color(bi1.getRGB(x, y)).equals(Color.WHITE)) {
  30. res = true;
  31. }
  32. if (res) {
  33. for (int p = 0; p <= h-1; p++) {
  34. b21.setRGB(x1,p,new Color(bi1.getRGB(x, p)).getRGB());
  35. }
  36. x1++;
  37. res = false;
  38. break;
  39. }
  40. }
  41. }
  42.  
  43. for (int y = 0; y <= h-1; y++) {
  44. System.out.println("Y = "+y);
  45. for (int x = 0; x <= x1-1; x++) {
  46. System.out.println("("+x+","+y+") : "+b21.getRGB(x, y));
  47. if (!new Color(b21.getRGB(x, y)).equals(Color.WHITE)) {
  48. res = true;
  49. }
  50. if (res) {
  51. for (int p = 0; p <= x1-1; p++) {
  52. b31.setRGB(p,y1,new Color(b21.getRGB(p, y)).getRGB());
  53.  
  54. }
  55. y1++;
  56. res = false;
  57. break;
  58. }
  59. }
  60. }
  61. b31=new BufferedImage(x1,y1,BufferedImage.TYPE_INT_RGB);
  62. int ty=y1;
  63. y1=0;
  64. for (int y = 0; y <= h-1; y++) {
  65. for (int x = 0; x <= x1-1; x++) {
  66. if (!new Color(b21.getRGB(x, y)).equals(Color.WHITE)) {
  67. res = true;
  68. }
  69. if (res) {
  70. for (int p = 0; p <= x1-1; p++) {
  71. b31.setRGB(p,y1,new Color(b21.getRGB(p, y)).getRGB());
  72. }
  73. y1++;
  74. res = false;
  75. break;
  76. }
  77. }
  78. }
  79.  
  80. if (!new Color(b21.getRGB(x, y)).equals(Color.WHITE))
  81.  
  82. if (new Color(b21.getRGB(x, y)).getRGB()<-1000000)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement