Java ByteBuffer Size makeTarget(BufferedImage image, int x, int y, int width, int height)

Here you can find the source of makeTarget(BufferedImage image, int x, int y, int width, int height)

Description

make Target

License

Apache License

Declaration

public static int[][] makeTarget(BufferedImage image, int x, int y, int width, int height) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.awt.image.BufferedImage;

public class Main {
    public static int[][] makeTarget(BufferedImage image, int x, int y, int width, int height) {
        int[][] target = new int[height][width];
        for (int i = 0; i < height; ++i) {
            for (int j = 0; j < width; ++j) {
                int argb = image.getRGB(j + x, i + y);
                int a = (argb >> 24) & 0xFF;
                int r = (argb >> 16) & 0xFF;
                int g = (argb >> 8) & 0xFF;
                int b = argb & 0xFF;

                if (a == 0) {
                    target[i][j] = -1;//from   w w  w .  j ava2  s .  co  m
                } else {
                    target[i][j] = ((299 * r + 587 * g + 114 * b) + 500) / 1000;
                }
            }
        }

        return target;

    }
}

Related

  1. FindResolution(BufferedImage img, double print_width, double print_height)
  2. fitToSize(BufferedImage source, int targetWidth, int targetHeight)
  3. generateScaledImage(final BufferedImage bufImg, @SuppressWarnings("unused") final Object hintsArg, final int size)
  4. makeBrighterRectangleOnImage(BufferedImage image, int leftPosition, int topPosition, int width, int height, double scaleFactor, Color borderColor, Stroke borderStroke)
  5. makeOval(BufferedImage input, int width, int height)
  6. mapByteBuffer(File cachedFile, int cacheFileSize)
  7. markDifferencesWithAMarker(final BufferedImage image, final Point[] pixels, final int markingSizeX, final int markingSizeY)
  8. markDifferencesWithBoxes(final BufferedImage image, final Point[] pixels, final int markingSizeX, final int markingSizeY)
  9. maybeGrow(List l, int size)