private static void getGlobalClientRect(long hwnd, Rect rect) { rect_buffer.put(0, 0).put(1, 0); clientToScreen(hwnd, rect_buffer); int offset_x = rect_buffer.get(0); int offset_y = rect_buffer.get(1); getClientRect(hwnd, rect_buffer); rect.copyFromBuffer(rect_buffer); rect.offset(offset_x, offset_y); }
private void readPalette() { RandomAccessFile rIn = null; ByteBuffer buf = null; int i; try { if (paletteFile != null) { // see if the file exists, if not, set it to the default palette. File file = new File(paletteFile); numPaletteEntries = (int) (file.length() / 4); buf = ByteBuffer.allocate(numPaletteEntries * 4); rIn = new RandomAccessFile(paletteFile, "r"); FileChannel inChannel = rIn.getChannel(); inChannel.position(0); inChannel.read(buf); // Check the byte order. buf.order(ByteOrder.LITTLE_ENDIAN); buf.rewind(); IntBuffer ib = buf.asIntBuffer(); paletteData = new int[numPaletteEntries]; ib.get(paletteData); ib = null; } } catch (Exception e) { System.err.println("Caught exception: " + e.toString()); System.err.println(e.getStackTrace()); } finally { if (rIn != null) { try { rIn.close(); } catch (Exception e) { } } } }
public void copyFromBuffer(IntBuffer buffer) { top = buffer.get(0); bottom = buffer.get(1); left = buffer.get(2); right = buffer.get(3); }