Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
/*
 * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
 * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 */

import java.awt.image.BufferedImage;
import java.nio.IntBuffer;

import javafx.scene.image.PixelFormat;

import javafx.scene.image.WritablePixelFormat;

public class Main {
    /**
     * Determine the appropriate {@link WritablePixelFormat} type that can
     * be used to transfer data into the indicated BufferedImage.
     * 
     * @param bimg the BufferedImage that will be used as a destination for
     *             a {@code PixelReader<IntBuffer>#getPixels()} operation.
     * @return 
     */
    private static WritablePixelFormat<IntBuffer> getAssociatedPixelFormat(BufferedImage bimg) {
        switch (bimg.getType()) {
        // We lie here for xRGB, but we vetted that the src data was opaque
        // so we can ignore the alpha.  We use ArgbPre instead of Argb
        // just to get a loop that does not have divides in it if the
        // PixelReader happens to not know the data is opaque.
        case BufferedImage.TYPE_INT_RGB:
        case BufferedImage.TYPE_INT_ARGB_PRE:
            return PixelFormat.getIntArgbPreInstance();
        case BufferedImage.TYPE_INT_ARGB:
            return PixelFormat.getIntArgbInstance();
        default:
            // Should not happen...
            throw new InternalError("Failed to validate BufferedImage type");
        }
    }
}