/** * Gets the width of this raster in byte-packed form * <p> * This method is used to provide backward API compatibility with BEAM versions prior 4.1. * Its use is discouraged.</p> * * @return the width of this raster in byte-packed form * @see #createBytePackedBitmaskRasterData() */ public final int getBytePackedBitmaskRasterWidth() { int bytePackedBitmaskRasterWidth = getWidth() / 8; if (getWidth() % 8 != 0) { bytePackedBitmaskRasterWidth++; } return bytePackedBitmaskRasterWidth; } }
/** * Sets a valid-mask for the given ID. * * @param id the ID * @param validMask the pixel mask * * @see #createValidMask(String, com.bc.ceres.core.ProgressMonitor) * @deprecated since BEAM 4.7, use {@link #getMaskGroup()} instead */ @Deprecated public void setValidMask(final String id, final BitRaster validMask) { if (validMask != null) { Guardian.assertEquals("validMask", validMask.getWidth(), getSceneRasterWidth()); Guardian.assertEquals("validMask", validMask.getHeight(), getSceneRasterHeight()); if (validMasks == null) { validMasks = new HashMap<>(); } validMasks.put(id, validMask); } else { if (validMasks != null) { validMasks.remove(id); } } }
/** * Creates a byte-packed bitmask as array of bytes. * <p> * This method is used to provide backward API compatibility with BEAM versions prior 4.1. * Its use is discouraged.</p> * * @return an array of bytes of size {@link #getBytePackedBitmaskRasterWidth()}<code> * </code>{@link #getHeight()} * @see #getBytePackedBitmaskRasterWidth() */ public byte[] createBytePackedBitmaskRasterData() { int packedWidth = getBytePackedBitmaskRasterWidth(); byte[] bytes = new byte[packedWidth * getHeight()]; for (int y = 0; y < getHeight(); y++) { for (int x = 0; x < getWidth(); x++) { bytes[(y * packedWidth + x)] |= (1 << (x % 8)); } } return bytes; }
private void testAccessors(BitRaster bitRaster, int x, int y) { assertEquals(false, bitRaster.isSet(x, y)); assertEquals(false, bitRaster.isSet(x + y * bitRaster.getWidth())); bitRaster.set(x, y, true); assertEquals(true, bitRaster.isSet(x, y)); assertEquals(true, bitRaster.isSet(x + y * bitRaster.getWidth())); bitRaster.set(x, y, false); assertEquals(false, bitRaster.isSet(x, y)); assertEquals(false, bitRaster.isSet(x + y * bitRaster.getWidth())); }
assertEquals(width, bitRaster.getWidth()); assertEquals(height, bitRaster.getHeight());