• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java ImageWriteException类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.commons.imaging.ImageWriteException的典型用法代码示例。如果您正苦于以下问题:Java ImageWriteException类的具体用法?Java ImageWriteException怎么用?Java ImageWriteException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ImageWriteException类属于org.apache.commons.imaging包,在下文中一共展示了ImageWriteException类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: updateXmpXml

import org.apache.commons.imaging.ImageWriteException; //导入依赖的package包/类
/**
 * Reads a Jpeg image, replaces the XMP XML and writes the result to a
 * stream.
 * 
 * @param byteSource
 *            ByteSource containing Jpeg image data.
 * @param os
 *            OutputStream to write the image to.
 * @param xmpXml
 *            String containing XMP XML.
 */
public void updateXmpXml(final ByteSource byteSource, final OutputStream os,
        final String xmpXml) throws ImageReadException, IOException,
        ImageWriteException {
    final JFIFPieces jfifPieces = analyzeJFIF(byteSource);
    List<JFIFPiece> pieces = jfifPieces.pieces;
    pieces = removeXmpSegments(pieces);

    final List<JFIFPieceSegment> newPieces = new ArrayList<JFIFPieceSegment>();
    final byte[] xmpXmlBytes = xmpXml.getBytes("utf-8");
    int index = 0;
    while (index < xmpXmlBytes.length) {
        final int segmentSize = Math.min(xmpXmlBytes.length, JpegConstants.MAX_SEGMENT_SIZE);
        final byte[] segmentData = writeXmpSegment(xmpXmlBytes, index,
                segmentSize);
        newPieces.add(new JFIFPieceSegment(JpegConstants.JPEG_APP1_MARKER, segmentData));
        index += segmentSize;
    }

    pieces = insertAfterLastAppSegments(pieces, newPieces);

    writeSegments(os, pieces);
}
 
开发者ID:windwardadmin,项目名称:android-awt,代码行数:34,代码来源:JpegXmpRewriter.java


示例2: writeChunkzTXt

import org.apache.commons.imaging.ImageWriteException; //导入依赖的package包/类
private void writeChunkzTXt(final OutputStream os, final PngText.Ztxt text) 
        throws IOException, ImageWriteException {
    if (!isValidISO_8859_1(text.keyword)) {
        throw new ImageWriteException("Png zTXt chunk keyword is not ISO-8859-1: " + text.keyword);
    }
    if (!isValidISO_8859_1(text.text)) {
        throw new ImageWriteException("Png zTXt chunk text is not ISO-8859-1: " + text.text);
    }

    final ByteArrayOutputStream baos = new ByteArrayOutputStream();

    // keyword
    baos.write(text.keyword.getBytes("ISO-8859-1"));
    baos.write(0);

    // compression method
    baos.write(PngConstants.COMPRESSION_DEFLATE_INFLATE);

    // text
    baos.write(deflate(text.text.getBytes("ISO-8859-1")));

    writeChunk(os, ChunkType.zTXt, baos.toByteArray());
}
 
开发者ID:windwardadmin,项目名称:android-awt,代码行数:24,代码来源:PngWriter.java


示例3: write

import org.apache.commons.imaging.ImageWriteException; //导入依赖的package包/类
@Override
  public void write(IIOMetadata iioMetadata, IIOImage iioImage, ImageWriteParam param)
          throws IOException {

      if (ios == null) {
          throw new IllegalArgumentException(Messages.getString("imageio.7F"));
      }

      RenderedImage img = null;
      if (!iioImage.hasRaster()) {
          img = iioImage.getRenderedImage();
          if (img instanceof BufferedImage) {
              sourceRaster = ((BufferedImage) img).getRaster();
          } else {
              sourceRaster = img.getData();
          }
      } else {
          sourceRaster = iioImage.getRaster();
      }

      Map params = new HashMap();
      try {
      	
	Imaging.writeImage((BufferedImage)img,
			wrapOutput(ios),//(OutputStream)ios,
			ImageFormats.JPEG,
			params);
} catch (ImageWriteException e) {
	// TODO Auto-generated catch block
	e.printStackTrace();
}
  }
 
开发者ID:windwardadmin,项目名称:android-awt,代码行数:33,代码来源:JPEGImageWriter.java


示例4: performNextMedianCut

import org.apache.commons.imaging.ImageWriteException; //导入依赖的package包/类
@Override
public boolean performNextMedianCut(final List<ColorGroup> colorGroups, final boolean ignoreAlpha)
        throws ImageWriteException {
    Collections.sort(colorGroups, COMPARATOR);
    final ColorGroup colorGroup = colorGroups.get(0);

    if (colorGroup.maxDiff == 0) {
        return false;
    }
    if (!ignoreAlpha
            && colorGroup.alphaDiff > colorGroup.redDiff
            && colorGroup.alphaDiff > colorGroup.greenDiff
            && colorGroup.alphaDiff > colorGroup.blueDiff) {
        doCut(colorGroup, ColorComponent.ALPHA, colorGroups, ignoreAlpha);
    } else if (colorGroup.redDiff > colorGroup.greenDiff
            && colorGroup.redDiff > colorGroup.blueDiff) {
        doCut(colorGroup, ColorComponent.RED, colorGroups, ignoreAlpha);
    } else if (colorGroup.greenDiff > colorGroup.blueDiff) {
        doCut(colorGroup, ColorComponent.GREEN, colorGroups, ignoreAlpha);
    } else {
        doCut(colorGroup, ColorComponent.BLUE, colorGroups, ignoreAlpha);
    }
    return true;
}
 
开发者ID:windwardadmin,项目名称:android-awt,代码行数:25,代码来源:MedianCutLongestAxisImplementation.java


示例5: getOutputSet

import org.apache.commons.imaging.ImageWriteException; //导入依赖的package包/类
public TiffOutputSet getOutputSet() throws ImageWriteException {
    final ByteOrder byteOrder = contents.header.byteOrder;
    final TiffOutputSet result = new TiffOutputSet(byteOrder);

    final List<? extends IImageMetadataItem> srcDirs = getDirectories();
    for (IImageMetadataItem srcDir1 : srcDirs) {
        final Directory srcDir = (Directory) srcDir1;

        if (null != result.findDirectory(srcDir.type)) {
            // Certain cameras right directories more than once.
            // This is a bug.
            // Ignore second directory of a given type.
            continue;
        }

        final TiffOutputDirectory outputDirectory = srcDir
                .getOutputDirectory(byteOrder);
        result.addDirectory(outputDirectory);
    }

    return result;
}
 
开发者ID:windwardadmin,项目名称:android-awt,代码行数:23,代码来源:TiffImageMetadata.java


示例6: writeStep

import org.apache.commons.imaging.ImageWriteException; //导入依赖的package包/类
private void writeStep(final BinaryOutputStream bos,
        final List<TiffOutputItem> outputItems) throws IOException,
        ImageWriteException {
    writeImageFileHeader(bos);

    for (TiffOutputItem outputItem : outputItems) {
        outputItem.writeItem(bos);

        final int length = outputItem.getItemLength();

        final int remainder = imageDataPaddingLength(length);
        for (int j = 0; j < remainder; j++) {
            bos.write(0);
        }
    }

}
 
开发者ID:windwardadmin,项目名称:android-awt,代码行数:18,代码来源:TiffImageWriterLossy.java


示例7: setData

import org.apache.commons.imaging.ImageWriteException; //导入依赖的package包/类
protected void setData(final byte[] bytes) throws ImageWriteException {
    // if(tagInfo.isUnknown())
    // Debug.debug("unknown tag(0x" + Integer.toHexString(tag)
    // + ") setData", bytes);

    if (this.bytes.length != bytes.length) {
        throw new ImageWriteException("Cannot change size of value.");
    }

    // boolean wasLocalValue = isLocalValue();
    this.bytes = bytes;
    if (separateValueItem != null) {
        separateValueItem.updateValue(bytes);
    }
    // if (isLocalValue() != wasLocalValue)
    // throw new Error("Bug. Locality disrupted! "
    // + tagInfo.getDescription());
}
 
开发者ID:windwardadmin,项目名称:android-awt,代码行数:19,代码来源:TiffOutputField.java


示例8: writeImage

import org.apache.commons.imaging.ImageWriteException; //导入依赖的package包/类
private void writeImage(Graphics2D graphicsTarget, Project project, File destinationFile, BufferedImage scaledImage, ImageTransformEntry validTransformEntry) {
    graphicsTarget.dispose();

    project.getLogger().info("Trying to write image-file: " + destinationFile.getAbsolutePath());
    try{
        // TODO handle incomplete Imaging-library
        // https://issues.apache.org/jira/browse/IMAGING-188
        Imaging.writeImage(scaledImage, destinationFile, validTransformEntry.format, new HashMap<>());
    } catch(IOException | ImageWriteException ex){
        project.getLogger().warn(null, ex);
    }
}
 
开发者ID:FibreFoX,项目名称:imagetransform-gradle-plugin,代码行数:13,代码来源:TransformTask.java


示例9: copyExifOrientation

import org.apache.commons.imaging.ImageWriteException; //导入依赖的package包/类
/**
 * This method will copy the Exif "orientation" information to the resulting image, if the
 * original image contains this data too.
 *
 * @param sourceImage
 *            The source image.
 * @param result
 *            The original result.
 * @return The new result containing the Exif orientation.
 */
public static byte[] copyExifOrientation(byte[] sourceImage, byte[] result) {
    try {
        ImageMetadata imageMetadata = Imaging.getMetadata(sourceImage);
        if (imageMetadata == null) {
            return result;
        }
        List<? extends ImageMetadata.ImageMetadataItem> metadataItems = imageMetadata
                .getItems();
        for (ImageMetadata.ImageMetadataItem metadataItem : metadataItems) {
            if (metadataItem instanceof TiffImageMetadata.TiffMetadataItem) {
                TiffField tiffField = ((TiffImageMetadata.TiffMetadataItem) metadataItem)
                        .getTiffField();
                if (!tiffField.getTagInfo().equals(TiffTagConstants.TIFF_TAG_ORIENTATION)) {
                    continue;
                }
                Object orientationValue = tiffField.getValue();
                if (orientationValue == null) {
                    break;
                }
                TiffOutputSet outputSet = new TiffOutputSet();
                TiffOutputDirectory outputDirectory = outputSet.getOrCreateRootDirectory();
                outputDirectory.add(TiffTagConstants.TIFF_TAG_ORIENTATION,
                        ((Number) orientationValue).shortValue());
                ByteArrayOutputStream outputStream = new ByteArrayOutputStream();

                new ExifRewriter().updateExifMetadataLossy(result, outputStream, outputSet);
                return outputStream.toByteArray();
            }
        }
    } catch (IOException | ImageWriteException | ImageReadException e) {
        LOGGER.warn("Error reading image: {}", e.getMessage());
    }
    return result;
}
 
开发者ID:Communote,项目名称:communote-server,代码行数:45,代码来源:ImageHelper.java


示例10: getPaletteIndex

import org.apache.commons.imaging.ImageWriteException; //导入依赖的package包/类
@Override
public int getPaletteIndex(final int rgb) throws ImageWriteException {
    final int precisionMask = (1 << precision) - 1;

    final int index = ((rgb >> (24 - 3 * precision)) & (precisionMask << (precision << 1)))
            | ((rgb >> (16 - 2 * precision)) & (precisionMask << precision))
            | ((rgb >> (8 - precision)) & (precisionMask));

    return straight[index].getIndex();
}
 
开发者ID:windwardadmin,项目名称:android-awt,代码行数:11,代码来源:QuantizedPalette.java


示例11: insertAfterLastAppSegments

import org.apache.commons.imaging.ImageWriteException; //导入依赖的package包/类
protected <T extends JFIFPiece, U extends JFIFPiece> List<JFIFPiece> insertAfterLastAppSegments(
        final List<T> segments, final List<U> newSegments) throws ImageWriteException {
    int lastAppIndex = -1;
    for (int i = 0; i < segments.size(); i++) {
        final JFIFPiece piece = segments.get(i);
        if (!(piece instanceof JFIFPieceSegment)) {
            continue;
        }

        final JFIFPieceSegment segment = (JFIFPieceSegment) piece;
        if (segment.isAppSegment()) {
            lastAppIndex = i;
        }
    }

    final List<JFIFPiece> result = new ArrayList<JFIFPiece>(segments);
    if (lastAppIndex == -1) {
        if (segments.size() < 1) {
            throw new ImageWriteException("JPEG file has no APP segments.");
        }
        result.addAll(1, newSegments);
    } else {
        result.addAll(lastAppIndex + 1, newSegments);
    }

    return result;
}
 
开发者ID:windwardadmin,项目名称:android-awt,代码行数:28,代码来源:JpegRewriter.java


示例12: removeExifMetadata

import org.apache.commons.imaging.ImageWriteException; //导入依赖的package包/类
/**
 * Reads a Jpeg image, removes all EXIF metadata (by removing the APP1
 * segment), and writes the result to a stream.
 * <p>
 * 
 * @param byteSource
 *            ByteSource containing Jpeg image data.
 * @param os
 *            OutputStream to write the image to.
 */
public void removeExifMetadata(final ByteSource byteSource, final OutputStream os)
        throws ImageReadException, IOException, ImageWriteException {
    final JFIFPieces jfifPieces = analyzeJFIF(byteSource);
    final List<JFIFPiece> pieces = jfifPieces.pieces;

    // Debug.debug("pieces", pieces);

    // pieces.removeAll(jfifPieces.exifSegments);

    // Debug.debug("pieces", pieces);

    writeSegmentsReplacingExif(os, pieces, null);
}
 
开发者ID:windwardadmin,项目名称:android-awt,代码行数:24,代码来源:ExifRewriter.java


示例13: compressT4_1D

import org.apache.commons.imaging.ImageWriteException; //导入依赖的package包/类
public static byte[] compressT4_1D(final byte[] uncompressed, final int width,
        final int height, final boolean hasFill) throws ImageWriteException {
    final BitInputStreamFlexible inputStream = new BitInputStreamFlexible(new ByteArrayInputStream(uncompressed));
    final BitArrayOutputStream outputStream = new BitArrayOutputStream();
    if (hasFill) {
        T4_T6_Tables.EOL16.writeBits(outputStream);
    } else {
        T4_T6_Tables.EOL.writeBits(outputStream);
    }
    
    for (int y = 0; y < height; y++) {
        compress1DLine(inputStream, outputStream, null, width);
        if (hasFill) {
            int bitsAvailable = outputStream
                    .getBitsAvailableInCurrentByte();
            if (bitsAvailable < 4) {
                outputStream.flush();
                bitsAvailable = 8;
            }
            for (; bitsAvailable > 4; bitsAvailable--) {
                outputStream.writeBit(0);
            }
        }
        T4_T6_Tables.EOL.writeBits(outputStream);
        inputStream.flushCache();
    }
    
    return outputStream.toByteArray();
}
 
开发者ID:windwardadmin,项目名称:android-awt,代码行数:30,代码来源:T4AndT6Compression.java


示例14: writeExifSegment

import org.apache.commons.imaging.ImageWriteException; //导入依赖的package包/类
private byte[] writeExifSegment(final TiffImageWriterBase writer,
        final TiffOutputSet outputSet, final boolean includeEXIFPrefix)
        throws IOException, ImageWriteException {
    final ByteArrayOutputStream os = new ByteArrayOutputStream();

    if (includeEXIFPrefix) {
        JpegConstants.EXIF_IDENTIFIER_CODE.writeTo(os);
        os.write(0);
        os.write(0);
    }

    writer.write(os, outputSet);

    return os.toByteArray();
}
 
开发者ID:windwardadmin,项目名称:android-awt,代码行数:16,代码来源:ExifRewriter.java


示例15: removeIPTC

import org.apache.commons.imaging.ImageWriteException; //导入依赖的package包/类
/**
 * Reads a Jpeg image, removes all IPTC data from the App13 segment but
 * leaves the other data in that segment (if present) unchanged and writes
 * the result to a stream.
 * <p>
 * 
 * @param byteSource
 *            ByteSource containing Jpeg image data.
 * @param os
 *            OutputStream to write the image to.
 */
public void removeIPTC(final ByteSource byteSource, final OutputStream os)
        throws ImageReadException, IOException, ImageWriteException {
    final JFIFPieces jfifPieces = analyzeJFIF(byteSource);
    final List<JFIFPiece> oldPieces = jfifPieces.pieces;
    final List<JFIFPiece> photoshopApp13Segments = findPhotoshopApp13Segments(oldPieces);

    if (photoshopApp13Segments.size() > 1) {
        throw new ImageReadException(
                "Image contains more than one Photoshop App13 segment.");
    }
    final List<JFIFPiece> newPieces = removePhotoshopApp13Segments(oldPieces);
    if (photoshopApp13Segments.size() == 1) {
        final JFIFPieceSegment oldSegment = (JFIFPieceSegment) photoshopApp13Segments
                .get(0);
        final Map<String, Object> params = new HashMap<String, Object>();
        final PhotoshopApp13Data oldData = new IptcParser()
                .parsePhotoshopSegment(oldSegment.segmentData, params);
        final List<IptcBlock> newBlocks = oldData.getNonIptcBlocks();
        final List<IptcRecord> newRecords = new ArrayList<IptcRecord>();
        final PhotoshopApp13Data newData = new PhotoshopApp13Data(newRecords,
                newBlocks);
        final byte[] segmentBytes = new IptcParser()
                .writePhotoshopApp13Segment(newData);
        final JFIFPieceSegment newSegment = new JFIFPieceSegment(
                oldSegment.marker, segmentBytes);
        newPieces.add(oldPieces.indexOf(oldSegment), newSegment);
    }
    writeSegments(os, newPieces);
}
 
开发者ID:windwardadmin,项目名称:android-awt,代码行数:41,代码来源:JpegIptcRewriter.java


示例16: writeIPTC

import org.apache.commons.imaging.ImageWriteException; //导入依赖的package包/类
/**
 * Reads a Jpeg image, replaces the IPTC data in the App13 segment but
 * leaves the other data in that segment (if present) unchanged and writes
 * the result to a stream.
 * 
 * @param byteSource
 *            ByteSource containing Jpeg image data.
 * @param os
 *            OutputStream to write the image to.
 * @param newData
 *            structure containing IPTC data.
 */
public void writeIPTC(final ByteSource byteSource, final OutputStream os,
        PhotoshopApp13Data newData) throws ImageReadException, IOException,
        ImageWriteException {
    final JFIFPieces jfifPieces = analyzeJFIF(byteSource);
    final List<JFIFPiece> oldPieces = jfifPieces.pieces;
    final List<JFIFPiece> photoshopApp13Segments = findPhotoshopApp13Segments(oldPieces);

    if (photoshopApp13Segments.size() > 1) {
        throw new ImageReadException(
                "Image contains more than one Photoshop App13 segment.");
    }
    List<JFIFPiece> newPieces = removePhotoshopApp13Segments(oldPieces);

    {
        // discard old iptc blocks.
        final List<IptcBlock> newBlocks = newData.getNonIptcBlocks();
        final byte[] newBlockBytes = new IptcParser().writeIPTCBlock(newData.getRecords());

        final int blockType = IptcConstants.IMAGE_RESOURCE_BLOCK_IPTC_DATA;
        final byte[] blockNameBytes = new byte[0];
        final IptcBlock newBlock = new IptcBlock(blockType, blockNameBytes, newBlockBytes);
        newBlocks.add(newBlock);

        newData = new PhotoshopApp13Data(newData.getRecords(), newBlocks);

        byte[] segmentBytes = new IptcParser().writePhotoshopApp13Segment(newData);
        JFIFPieceSegment newSegment = new JFIFPieceSegment(JpegConstants.JPEG_APP13_MARKER, segmentBytes);

        newPieces = insertAfterLastAppSegments(newPieces, Arrays.asList(newSegment));
    }

    writeSegments(os, newPieces);
}
 
开发者ID:windwardadmin,项目名称:android-awt,代码行数:46,代码来源:JpegIptcRewriter.java


示例17: writeImage

import org.apache.commons.imaging.ImageWriteException; //导入依赖的package包/类
@Override
public void writeImage(final BufferedImage src, final OutputStream os, final Map<String, Object> params)
        throws ImageWriteException, IOException {
    // System.out.println
    // (b1 == 0x50 && b2 == 0x36)
    os.write(0x50);
    os.write(rawbits ? 0x35 : 0x32);
    os.write(PnmConstants.PNM_SEPARATOR);

    final int width = src.getWidth();
    final int height = src.getHeight();

    os.write(Integer.toString(width).getBytes("US-ASCII"));
    os.write(PnmConstants.PNM_SEPARATOR);

    os.write(Integer.toString(height).getBytes("US-ASCII"));
    os.write(PnmConstants.PNM_SEPARATOR);

    os.write(Integer.toString(255).getBytes("US-ASCII")); // max component value
    os.write(PnmConstants.PNM_NEWLINE);

    for (int y = 0; y < height; y++) {
        for (int x = 0; x < width; x++) {
            final int argb = src.getRGB(x, y);
            final int red = 0xff & (argb >> 16);
            final int green = 0xff & (argb >> 8);
            final int blue = 0xff & (argb >> 0);
            final int sample = (red + green + blue) / 3;

            if (rawbits) {
                os.write((byte) sample);
            } else {
                os.write(Integer.toString(sample).getBytes("US-ASCII")); // max component value
                os.write(PnmConstants.PNM_SEPARATOR);
            }
        }
    }
}
 
开发者ID:windwardadmin,项目名称:android-awt,代码行数:39,代码来源:PgmWriter.java


示例18: writeScanLine

import org.apache.commons.imaging.ImageWriteException; //导入依赖的package包/类
private void writeScanLine(final BinaryOutputStream bos, final byte[] scanline)
        throws IOException, ImageWriteException {
    if (encoding == PcxImageParser.PcxHeader.ENCODING_UNCOMPRESSED) {
        bos.write(scanline);
    } else {
        if (encoding == PcxImageParser.PcxHeader.ENCODING_RLE) {
            int previousByte = -1;
            int repeatCount = 0;
            for (final byte element : scanline) {
                if ((element & 0xff) == previousByte
                        && repeatCount < 63) {
                    ++repeatCount;
                } else {
                    if (repeatCount > 0) {
                        if (repeatCount == 1
                                && (previousByte & 0xc0) != 0xc0) {
                            bos.write(previousByte);
                        } else {
                            bos.write(0xc0 | repeatCount);
                            bos.write(previousByte);
                        }
                    }
                    previousByte = 0xff & element;
                    repeatCount = 1;
                }
            }
            if (repeatCount > 0) {
                if (repeatCount == 1 && (previousByte & 0xc0) != 0xc0) {
                    bos.write(previousByte);
                } else {
                    bos.write(0xc0 | repeatCount);
                    bos.write(previousByte);
                }
            }
        } else {
            throw new ImageWriteException("Invalid PCX encoding "
                    + encoding);
        }
    }
}
 
开发者ID:windwardadmin,项目名称:android-awt,代码行数:41,代码来源:PcxWriter.java


示例19: write24BppPCX

import org.apache.commons.imaging.ImageWriteException; //导入依赖的package包/类
private void write24BppPCX(final BufferedImage src, final BinaryOutputStream bos)
        throws ImageWriteException, IOException {
    final int bytesPerLine = src.getWidth() % 2 == 0 ? src.getWidth() : src
            .getWidth() + 1;

    // PCX header
    bos.write(10); // manufacturer
    bos.write(5); // version
    bos.write(encoding); // encoding
    bos.write(8); // bits per pixel
    bos.write2Bytes(0); // xMin
    bos.write2Bytes(0); // yMin
    bos.write2Bytes(src.getWidth() - 1); // xMax
    bos.write2Bytes(src.getHeight() - 1); // yMax
    bos.write2Bytes((short) Math.round(pixelDensity
            .horizontalDensityInches())); // hDpi
    bos.write2Bytes((short) Math.round(pixelDensity.verticalDensityInches())); // vDpi
    bos.write(new byte[48]); // 16 color palette
    bos.write(0); // reserved
    bos.write(3); // planes
    bos.write2Bytes(bytesPerLine); // bytes per line
    bos.write2Bytes(1); // palette info
    bos.write2Bytes(0); // hScreenSize
    bos.write2Bytes(0); // vScreenSize
    bos.write(new byte[54]);

    final int[] rgbs = new int[src.getWidth()];
    final byte[] rgbBytes = new byte[3 * bytesPerLine];
    for (int y = 0; y < src.getHeight(); y++) {
        src.getRGB(0, y, src.getWidth(), 1, rgbs, 0, src.getWidth());
        for (int x = 0; x < rgbs.length; x++) {
            rgbBytes[x] = (byte) ((rgbs[x] >> 16) & 0xff);
            rgbBytes[bytesPerLine + x] = (byte) ((rgbs[x] >> 8) & 0xff);
            rgbBytes[2 * bytesPerLine + x] = (byte) (rgbs[x] & 0xff);
        }
        writeScanLine(bos, rgbBytes);
    }
}
 
开发者ID:windwardadmin,项目名称:android-awt,代码行数:39,代码来源:PcxWriter.java


示例20: ColorGroup

import org.apache.commons.imaging.ImageWriteException; //导入依赖的package包/类
public ColorGroup(final List<ColorCount> colorCounts, final boolean ignoreAlpha) throws ImageWriteException {
    this.colorCounts = colorCounts;
    this.ignoreAlpha = ignoreAlpha;

    if (colorCounts.size() < 1) {
        throw new ImageWriteException("empty color_group");
    }

    int total = 0;
    for (ColorCount color : colorCounts) {
        total += color.count;

        minAlpha = Math.min(minAlpha, color.alpha);
        maxAlpha = Math.max(maxAlpha, color.alpha);
        minRed = Math.min(minRed, color.red);
        maxRed = Math.max(maxRed, color.red);
        minGreen = Math.min(minGreen, color.green);
        maxGreen = Math.max(maxGreen, color.green);
        minBlue = Math.min(minBlue, color.blue);
        maxBlue = Math.max(maxBlue, color.blue);
    }
    this.totalPoints = total;

    alphaDiff = maxAlpha - minAlpha;
    redDiff = maxRed - minRed;
    greenDiff = maxGreen - minGreen;
    blueDiff = maxBlue - minBlue;
    maxDiff = Math.max(
            ignoreAlpha ? redDiff : Math.max(alphaDiff, redDiff),
            Math.max(greenDiff, blueDiff));
    diffTotal = (ignoreAlpha ? 0 : alphaDiff) + redDiff + greenDiff + blueDiff;
}
 
开发者ID:windwardadmin,项目名称:android-awt,代码行数:33,代码来源:ColorGroup.java



注:本文中的org.apache.commons.imaging.ImageWriteException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java BEDCodec类代码示例发布时间:2022-05-22
下一篇:
Java BufferManagerReadStream类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap