Changeset 221
- Timestamp:
- 04/22/06 13:07:33 (2 years ago)
- Files:
-
- misc/java/src/edu/cmu/cs/cc3/misc/FakePixbuf.java (modified) (1 diff)
- misc/java/src/edu/cmu/cs/cc3/misc/Pixbuf.java (modified) (3 diffs)
- misc/java/src/edu/cmu/cs/cc3/misc/Test.java (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
misc/java/src/edu/cmu/cs/cc3/misc/FakePixbuf.java
r220 r221 9 9 10 10 public FakePixbuf() { 11 super(); 12 13 rawWidth = 88 * 2; 14 rawHeight = 144; 11 super(88 * 2, 144); 15 12 16 13 // load the image misc/java/src/edu/cmu/cs/cc3/misc/Pixbuf.java
r220 r221 10 10 final static public int CHANNEL_ALL = 3; 11 11 12 int rawWidth, rawHeight;12 final int rawWidth, rawHeight; 13 13 14 int x0, y0, x1 = rawWidth + 1, y1 = rawHeight +1;14 int x0, y0, x1, y1; 15 15 16 16 int yLoc; … … 22 22 int width, height; 23 23 24 public Pixbuf() { 24 Pixbuf(int rawW, int rawH) { 25 rawWidth = rawW; 26 rawHeight = rawH; 27 28 x1 = rawWidth; 29 y1 = rawHeight; 30 25 31 updateFrameBounds(); 26 32 } … … 93 99 public byte[] allocateRows(int rows) { 94 100 int p = coi == CHANNEL_ALL ? 3 : 1; 101 102 System.out.println("allocate " + p + " * " + getWidth() + " * " + rows); 103 95 104 return new byte[p * getWidth() * rows]; 96 105 } misc/java/src/edu/cmu/cs/cc3/misc/Test.java
r220 r221 22 22 j.setSize(400, 400); 23 23 24 JLabel jp = new JLabel();25 26 24 j.setBackground(Color.BLACK); 27 25 … … 29 27 ColorSpace.TYPE_RGB); 30 28 31 jp.setIcon(new ImageIcon(b)); 32 jp.setBackground(Color.BLACK); 29 fillImage(b, p); 30 31 System.out.println(b); 32 33 JLabel jp = new JLabel(new ImageIcon(b)); 33 34 j.getContentPane().add(jp); 34 35 35 36 j.setVisible(true); 36 37 } 37 38 38 39 39 private static void fillImage(BufferedImage b, Pixbuf p) { 40 p.rewind(); 41 42 byte row[] = p.allocateRows(1); 43 44 System.out.println(row.length); 45 System.out.println("w: " + p.getWidth() + ", h: " + p.getHeight()); 46 for (int y = 0; y < p.getHeight(); y++) { 47 int i = 0; 48 p.readRows(row, 1); 49 for (int x = 0; x < p.getWidth(); x++) { 50 b.setRGB(x, y, row[i] << 16 | row[i + 1] << 8 | row[i + 2]); 51 i += 3; 52 } 53 } 54 } 55 40 56 }
