| 1026 | |
| 1027 | |
| 1028 | protected void readBitmap(DataInputStream is) throws IOException { |
| 1029 | image = new PImage(width, height, ALPHA); |
| 1030 | int bitmapSize = width * height; |
| 1031 | |
| 1032 | byte[] temp = new byte[bitmapSize]; |
| 1033 | is.readFully(temp); |
| 1034 | |
| 1035 | // convert the bitmap to an alpha channel |
| 1036 | int w = width; |
| 1037 | int h = height; |
| 1038 | int[] pixels = image.pixels; |
| 1039 | for (int y = 0; y < h; y++) { |
| 1040 | for (int x = 0; x < w; x++) { |
| 1041 | pixels[y * width + x] = temp[y*w + x] & 0xff; |
| 1042 | // System.out.print((image.pixels[y*64+x] > 128) ? "*" : "."); |
| 1043 | } |
| 1044 | // System.out.println(); |
| 1045 | } |
| 1046 | // System.out.println(); |
| 1047 | } |
| 1048 | |
| 1049 | |
| 1050 | protected void writeBitmap(DataOutputStream os) throws IOException { |