src/share/classes/com/sun/imageio/plugins/bmp/BMPImageWriter.java

Print this page




 565         // Buffer for up to 8 rows of pixels
 566         int[] pixels = new int[scanlineBytes * scaleX];
 567 
 568         // Also create a buffer to hold one line of the data
 569         // to be written to the file, so we can use array writes.
 570         bpixels = new byte[destScanlineBytes];
 571 
 572         int l;
 573 
 574         if (compressionType == BMPConstants.BI_JPEG ||
 575             compressionType == BMPConstants.BI_PNG) {
 576 
 577             // prepare embedded buffer
 578             embedded_stream = new ByteArrayOutputStream();
 579             writeEmbedded(image, bmpParam);
 580             // update the file/image Size
 581             embedded_stream.flush();
 582             imageSize = embedded_stream.size();
 583 
 584             long endPos = stream.getStreamPosition();
 585             fileSize = (int)(offset + imageSize);
 586             stream.seek(headPos);
 587             writeSize(fileSize, 2);
 588             stream.seek(headPos);
 589             writeSize(imageSize, 34);
 590             stream.seek(endPos);
 591             stream.write(embedded_stream.toByteArray());
 592             embedded_stream = null;
 593 
 594             if (abortRequested()) {
 595                 processWriteAborted();
 596             } else {
 597                 processImageComplete();
 598                 stream.flushBefore(stream.getStreamPosition());
 599             }
 600 
 601             return;
 602         }
 603 
 604         int maxBandOffset = bandOffsets[0];
 605         for (int i = 1; i < bandOffsets.length; i++)




 565         // Buffer for up to 8 rows of pixels
 566         int[] pixels = new int[scanlineBytes * scaleX];
 567 
 568         // Also create a buffer to hold one line of the data
 569         // to be written to the file, so we can use array writes.
 570         bpixels = new byte[destScanlineBytes];
 571 
 572         int l;
 573 
 574         if (compressionType == BMPConstants.BI_JPEG ||
 575             compressionType == BMPConstants.BI_PNG) {
 576 
 577             // prepare embedded buffer
 578             embedded_stream = new ByteArrayOutputStream();
 579             writeEmbedded(image, bmpParam);
 580             // update the file/image Size
 581             embedded_stream.flush();
 582             imageSize = embedded_stream.size();
 583 
 584             long endPos = stream.getStreamPosition();
 585             fileSize = offset + imageSize;
 586             stream.seek(headPos);
 587             writeSize(fileSize, 2);
 588             stream.seek(headPos);
 589             writeSize(imageSize, 34);
 590             stream.seek(endPos);
 591             stream.write(embedded_stream.toByteArray());
 592             embedded_stream = null;
 593 
 594             if (abortRequested()) {
 595                 processWriteAborted();
 596             } else {
 597                 processImageComplete();
 598                 stream.flushBefore(stream.getStreamPosition());
 599             }
 600 
 601             return;
 602         }
 603 
 604         int maxBandOffset = bandOffsets[0];
 605         for (int i = 1; i < bandOffsets.length; i++)