private byte[] getTile(byte[] buf, Region tileParams, Region srcParams) { MetadataRetrieve retrieve = getMetadataRetrieve(); int type = FormatTools.pixelTypeFromString(retrieve.getPixelsType(series).toString()); int channel_count = getSamplesPerPixel(); int bytesPerPixel = FormatTools.getBytesPerPixel(type); int tileSize = tileParams.width * tileParams.height * bytesPerPixel * channel_count; byte [] returnBuf = new byte[tileSize]; for (int row = tileParams.y; row != tileParams.y + tileParams.height; row++) { for (int sampleoffset = 0; sampleoffset < (tileParams.width * channel_count); sampleoffset++) { int channel_index = sampleoffset / tileParams.width; int channel_offset = (sampleoffset - (tileParams.width * channel_index)) * bytesPerPixel; int full_row_width = srcParams.width * bytesPerPixel; int full_plane_size = full_row_width * srcParams.height; int xoffset = (tileParams.x - srcParams.x) * bytesPerPixel; int yoffset = (row - srcParams.y) * full_row_width; int row_offset = (row - tileParams.y) * tileParams.width * bytesPerPixel; int src_index = yoffset + xoffset + channel_offset + (channel_index * full_plane_size); int dest_index = (tileParams.height * tileParams.width * channel_index * bytesPerPixel) + row_offset; for (int pixelByte = 0; pixelByte < bytesPerPixel; pixelByte++) { returnBuf[dest_index + channel_offset + pixelByte] = buf[src_index + pixelByte]; } } } return returnBuf; }
private byte[] getTile(byte[] buf, Region tileParams, Region srcParams) { MetadataRetrieve retrieve = getMetadataRetrieve(); int type = FormatTools.pixelTypeFromString(retrieve.getPixelsType(series).toString()); int channel_count = getSamplesPerPixel(); int bytesPerPixel = FormatTools.getBytesPerPixel(type); int tileSize = tileParams.width * tileParams.height * bytesPerPixel * channel_count; byte [] returnBuf = new byte[tileSize]; for (int row = tileParams.y; row != tileParams.y + tileParams.height; row++) { for (int sampleoffset = 0; sampleoffset < (tileParams.width * channel_count); sampleoffset++) { int channel_index = sampleoffset / tileParams.width; int channel_offset = (sampleoffset - (tileParams.width * channel_index)) * bytesPerPixel; int full_row_width = srcParams.width * bytesPerPixel; int full_plane_size = full_row_width * srcParams.height; int xoffset = (tileParams.x - srcParams.x) * bytesPerPixel; int yoffset = (row - srcParams.y) * full_row_width; int row_offset = (row - tileParams.y) * tileParams.width * bytesPerPixel; int src_index = yoffset + xoffset + channel_offset + (channel_index * full_plane_size); int dest_index = (tileParams.height * tileParams.width * channel_index * bytesPerPixel) + row_offset; for (int pixelByte = 0; pixelByte < bytesPerPixel; pixelByte++) { returnBuf[dest_index + channel_offset + pixelByte] = buf[src_index + pixelByte]; } } } return returnBuf; }
int c = getSamplesPerPixel(); int type = FormatTools.pixelTypeFromString( retrieve.getPixelsType(series).toString()); interleaved || getSamplesPerPixel() == 1 ? 1 : 2);
int c = getSamplesPerPixel(); int type = FormatTools.pixelTypeFromString( retrieve.getPixelsType(series).toString()); interleaved || getSamplesPerPixel() == 1 ? 1 : 2);