当前位置: 首页>>代码示例>>Java>>正文


Java ImageLineInt类代码示例

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


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

示例1: getPixelValues

import ar.com.hjg.pngj.ImageLineInt; //导入依赖的package包/类
/**
 * Get the pixel values of the image as 16 bit unsigned integer values
 *
 * @param imageBytes image bytes
 * @return 16 bit unsigned integer pixel values
 */
public int[] getPixelValues(byte[] imageBytes) {

    PngReaderInt reader = new PngReaderInt(new ByteArrayInputStream(imageBytes));
    validateImageType(reader);
    int[] pixels = new int[reader.imgInfo.cols * reader.imgInfo.rows];
    int rowNumber = 0;
    while (reader.hasMoreRows()) {
        ImageLineInt row = reader.readRowInt();
        int[] rowValues = row.getScanline();
        System.arraycopy(rowValues, 0, pixels, rowNumber * reader.imgInfo.cols, rowValues.length);
        rowNumber++;
    }
    reader.close();

    return pixels;
}
 
开发者ID:ngageoint,项目名称:geopackage-android,代码行数:23,代码来源:ElevationTilesPng.java

示例2: drawTile

import ar.com.hjg.pngj.ImageLineInt; //导入依赖的package包/类
/**
 * Draw an elevation image tile from the flat array of "unsigned short"
 * pixel values of length tileWidth * tileHeight where each pixel is at: (y
 * * tileWidth) + x
 *
 * @param pixelValues "unsigned short" pixel values of length tileWidth * tileHeight
 * @param tileWidth   tile width
 * @param tileHeight  tile height
 * @return elevation image tile
 */
public ElevationPngImage drawTile(short[] pixelValues, int tileWidth,
                                  int tileHeight) {

    ElevationPngImage image = createImage(tileWidth, tileHeight);
    PngWriter writer = image.getWriter();
    for (int y = 0; y < tileHeight; y++) {
        ImageLineInt row = new ImageLineInt(writer.imgInfo, new int[tileWidth]);
        int[] rowLine = row.getScanline();
        for (int x = 0; x < tileWidth; x++) {
            short pixelValue = pixelValues[(y * tileWidth) + x];
            setPixelValue(rowLine, x, pixelValue);
        }
        writer.writeRow(row);
    }
    writer.end();
    image.flushStream();

    return image;
}
 
开发者ID:ngageoint,项目名称:geopackage-android,代码行数:30,代码来源:ElevationTilesPng.java

示例3: exportRegions

import ar.com.hjg.pngj.ImageLineInt; //导入依赖的package包/类
@Override
public void exportRegions(ImageLineInt[] lines, int x1, int x2, int rY) {
    int[] temp = new int[4 * 512];
    temp[3] = 255;
    for (int rX = x1; rX < x2; rX++) {
        int scanOff = (rX - x1) * REGION_SIZE_SCAN;
        File outFile = getFile(rX, rY);
        BufferedImage image = new BufferedImage(512, 512, BufferedImage.TYPE_INT_RGB);
        for (int y = 0; y < 512; y++) {
            int[] scan = lines[y].getScanline();//rgb
            for (int x = 0; x < 512; x++) {
                int off = x * 3;
                temp[off] = scan[scanOff + off];
                temp[off + 1] = scan[scanOff + off + 1];
                temp[off + 2] = scan[scanOff + off + 2];
            }
            image.getRaster().setPixels(0, y, 512, 1, temp); //rgba
        }
        try {
            ImageIO.write(image, "PNG", outFile);
        } catch (IOException e) {
            throw new RuntimeException("Exception exporting region at " + rX + "," + rY + "!", e);
        }
    }
}
 
开发者ID:warriordog,项目名称:MapMaster,代码行数:26,代码来源:PNGExport.java

示例4: copyScales

import ar.com.hjg.pngj.ImageLineInt; //导入依赖的package包/类
public static void copyScales(ImageLineInt[] lines) {
    for (int index = 0; index < writers.length; index++) {
        int scale = (int) Math.pow(2, index + 1);
        PngWriter writer = writers[index];
        ImageLineInt outLine = new ImageLineInt(writer.imgInfo);
        int[] outScan = outLine.getScanline();
        for (int i = 0; i < lines.length; i += scale) {
            ImageLineInt inLine = lines[i];
            int[] inScan = inLine.getScanline();
            for (int outIndex = 0; outIndex < outScan.length - 3; outIndex += 3) {
                int inIndex = outIndex * scale;
                if (inIndex + 3 >= inScan.length) {
                    break; //cut short in case size does not line up exactly.
                }
                System.arraycopy(inScan, inIndex, outScan, outIndex, 3);
            }
            writer.writeRow(outLine);
        }
    }
}
 
开发者ID:warriordog,项目名称:MapMaster,代码行数:21,代码来源:MapScaler.java

示例5: writePngImage

import ar.com.hjg.pngj.ImageLineInt; //导入依赖的package包/类
/**
     * Writes a {@link BufferedImage} to the specified {@link OutputStream} using the PNGJ library
     * which is much faster than Java's ImageIO library.
     *
     * This implementation was copied from
     * <a href="https://github.com/leonbloy/pngj/wiki/Snippets">
     *     https://github.com/leonbloy/pngj/wiki/Snippets
     * </a>.
     *
     * @param  bufferedImage     image to write.
     * @param  compressionLevel  0 (no compression) - 9 (max compression)
     * @param  filterType        internal prediction filter type.
     * @param  outputStream      target stream.
     *
     * @throws IOException
     *   if the image is not ARGB or it's data buffer contains the wrong number of banks.
     */
    public static void writePngImage(final BufferedImage bufferedImage,
                                     final int compressionLevel,
                                     final FilterType filterType,
                                     final OutputStream outputStream)
            throws IOException {

        if (bufferedImage.getType() != BufferedImage.TYPE_INT_ARGB) {
            throw new IOException("invalid image type (" + bufferedImage.getType() +
                                  "), must be BufferedImage.TYPE_INT_ARGB");
        }

        final ImageInfo imageInfo = new ImageInfo(bufferedImage.getWidth(), bufferedImage.getHeight(), 8, true);

        final PngWriter pngWriter = new PngWriter(outputStream, imageInfo);
        pngWriter.setCompLevel(compressionLevel);
        pngWriter.setFilterType(filterType);

        final DataBufferInt dataBuffer =((DataBufferInt) bufferedImage.getRaster().getDataBuffer());
        if (dataBuffer.getNumBanks() != 1) {
            throw new IOException("invalid number of banks (" + dataBuffer.getNumBanks() + "), must be 1");
        }

        final SinglePixelPackedSampleModel sampleModel = (SinglePixelPackedSampleModel) bufferedImage.getSampleModel();
        final ImageLineInt line = new ImageLineInt(imageInfo);
        final int[] data = dataBuffer.getData();
        for (int row = 0; row < imageInfo.rows; row++) {
            int elem = sampleModel.getOffset(0, row);
            for (int col = 0; col < imageInfo.cols; col++) {
                final int sample = data[elem++];
                ImageLineHelper.setPixelRGBA8(line, col, sample);
            }
            pngWriter.writeRow(line, row);
        }
        pngWriter.end();

//        // This looked like a nicer option, but only works for DataBufferByte (not DataBufferInt)
//        final ImageLineSetARGBbi lines = new ImageLineSetARGBbi(bufferedImage, imageInfo);
//        pngWriter.writeRows(lines);
//        pngWriter.end();
    }
 
开发者ID:saalfeldlab,项目名称:render,代码行数:58,代码来源:BufferedImageStreamingOutput.java

示例6: getPixelValue

import ar.com.hjg.pngj.ImageLineInt; //导入依赖的package包/类
/**
 * Get the pixel value as a 16 bit unsigned integer value
 *
 * @param imageBytes image bytes
 * @param x          x coordinate
 * @param y          y coordinate
 * @return pixel value
 */
public int getPixelValue(byte[] imageBytes, int x, int y) {

    PngReaderInt reader = new PngReaderInt(new ByteArrayInputStream(imageBytes));
    validateImageType(reader);
    ImageLineInt row = (ImageLineInt) reader.readRow(y);
    int pixelValue = row.getScanline()[x];
    reader.close();

    return pixelValue;
}
 
开发者ID:ngageoint,项目名称:geopackage-android,代码行数:19,代码来源:ElevationTilesPng.java

示例7: readPixels

import ar.com.hjg.pngj.ImageLineInt; //导入依赖的package包/类
/**
 * Read all the pixels from the image
 */
private void readPixels() {
    if (reader != null) {
        pixels = new int[reader.imgInfo.rows][reader.imgInfo.cols];
        int rowCount = 0;
        while (reader.hasMoreRows()) {
            ImageLineInt row = reader.readRowInt();
            int[] columnValues = new int[reader.imgInfo.cols];
            System.arraycopy(row.getScanline(), 0, columnValues, 0, columnValues.length);
            pixels[rowCount++] = columnValues;
        }
        reader.close();
    }
}
 
开发者ID:ngageoint,项目名称:geopackage-android,代码行数:17,代码来源:ElevationPngImage.java

示例8: convertToPNG

import ar.com.hjg.pngj.ImageLineInt; //导入依赖的package包/类
public void convertToPNG(Dds dds, OutputStream outputStream, String swizzle) throws IOException {
    DdsHeader header = dds.getHeader();
    FormatDecoder decoder = Decoders.getDecoder(dds);
    ImageInfo imageInfo = new ImageInfo(header.getDwWidth(), header.getDwHeight(), 8, true);
    PngWriter pngWriter = new PngWriter(outputStream, imageInfo);
    ImageLineInt imageLine = new ImageLineInt(imageInfo);
    for (int[] ints : decoder) {
        swizzle(ints, swizzle);
        ImageLineHelper.setPixelsRGBA8(imageLine, ints);
        pngWriter.writeRow(imageLine);
    }

    pngWriter.end();
}
 
开发者ID:vincentzhang96,项目名称:DDS4J,代码行数:15,代码来源:DdsImageDecoder.java

示例9: apply

import ar.com.hjg.pngj.ImageLineInt; //导入依赖的package包/类
@Override
public void apply(int row, ImageLineInt line) {
    if (currRow >= image.getHeight()) {
        throw new IllegalStateException("Attempted to draw overlay too many times: " + currRow);
    }
    ImageUtils.copyImageToPng(image, currRow, line, getXLoc(), true);
    currRow++;
}
 
开发者ID:warriordog,项目名称:MapMaster,代码行数:9,代码来源:ShapeOverlay.java

示例10: writeRegionsPre

import ar.com.hjg.pngj.ImageLineInt; //导入依赖的package包/类
public static void writeRegionsPre(ImageLineInt[] lines, int x1, int x2, int y, boolean changed) {
    if (changed) {
        for (Export export : preExports) {
            export.exportRegions(lines, x1, x2, y);
        }
    }
}
 
开发者ID:warriordog,项目名称:MapMaster,代码行数:8,代码来源:MapExporter.java

示例11: writeRegionsPost

import ar.com.hjg.pngj.ImageLineInt; //导入依赖的package包/类
public static void writeRegionsPost(ImageLineInt[] lines, int x1, int x2, int y, boolean changed) {
    if (changed) {
        for (Export export : postExports) {
            export.exportRegions(lines, x1, x2, y);
        }
    }
}
 
开发者ID:warriordog,项目名称:MapMaster,代码行数:8,代码来源:MapExporter.java

示例12: mergeTiles

import ar.com.hjg.pngj.ImageLineInt; //导入依赖的package包/类
public static void mergeTiles(MapScript script, PngWriter outImage) {
    //code moved out to avoid recalculating math millions of times in a tight loop
    int startXRegion = getRegionCoord(script.getX1());
    int endXRegion = getRegionCoord(script.getX2());
    int startYRegion = getRegionCoord(script.getY1());
    int endYRegion = getRegionCoord(script.getY2());

    //allocated here to avoid making millions of duplicates
    List<Tile> tileList = new ArrayList<>(script.getTileSources().length);

    //iterates through 32x32 chunk regions in the map image
    //some code sections are oddly placed for performance
    int row = 0;
    for (int yRegion = startYRegion; yRegion < endYRegion; yRegion++) {
        ImageLineInt[] lines = createRegionLines(outImage);
        boolean changed = false;
        for (int xRegion = startXRegion; xRegion < endXRegion; xRegion++) {
            getTilesForRegion(script, xRegion, yRegion, tileList); //results are in tileList
            if (tileList.size() > 0) {
                changed = true;
                for (Tile tile : tileList) {
                    copyBufferToScanLine(xRegion, lines, tile.getImage(), script);
                }

                tileList.clear();
            }
        }
        writeScanLines(lines, startXRegion, endXRegion, startYRegion, row, outImage, changed);
        row += lines.length;
    }
    int left = outImage.imgInfo.rows - row - 1;
    if (left > 0) {
        System.out.println(left + " PNG lines left, filling with blanks.");
        for (int i = 0; i <= left; i++) {
            outImage.writeRow(new ImageLineInt(outImage.imgInfo));
            row++;
        }
    }
}
 
开发者ID:warriordog,项目名称:MapMaster,代码行数:40,代码来源:MapMerger.java

示例13: writeScanLines

import ar.com.hjg.pngj.ImageLineInt; //导入依赖的package包/类
private static void writeScanLines(ImageLineInt[] lines, int x1, int x2, int y1, int row, PngWriter outImage, boolean changed) {
    int rY = y1 + (row / 512);
    MapExporter.writeRegionsPre(lines, x1, x2, rY, changed);
    for (int i = 0; i < lines.length; i++) {
        ImageLineInt line = lines[i];
        MapOverlay.writeIntoLine(row + i, line); //apply overlays
        outImage.writeRow(line);
    }
    MapExporter.writeRegionsPost(lines, x1, x2, rY, changed);
    MapScaler.copyScales(lines);
}
 
开发者ID:warriordog,项目名称:MapMaster,代码行数:12,代码来源:MapMerger.java

示例14: createRegionLines

import ar.com.hjg.pngj.ImageLineInt; //导入依赖的package包/类
private static ImageLineInt[] createRegionLines(PngWriter outImage) {
    ImageLineInt[] lines = new ImageLineInt[REGION_SIZE_PIXELS];
    for (int index = 0; index < REGION_SIZE_PIXELS; index++) {
        lines[index] = new ImageLineInt(outImage.imgInfo);
    }
    return lines;
}
 
开发者ID:warriordog,项目名称:MapMaster,代码行数:8,代码来源:MapMerger.java

示例15: writeIntoLine

import ar.com.hjg.pngj.ImageLineInt; //导入依赖的package包/类
public static void writeIntoLine(int row, ImageLineInt line) {
    List<Overlay> overlays = rowMap.get(row);
    if (overlays != null && overlays.size() > 0) {
        for (Overlay overlay : overlays) {
            overlay.apply(row, line);
        }
    }
}
 
开发者ID:warriordog,项目名称:MapMaster,代码行数:9,代码来源:MapOverlay.java


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