Java Image to BufferedImage imageToBufferedImage(Image pImage)

Here you can find the source of imageToBufferedImage(Image pImage)

Description

image To Buffered Image

License

Open Source License

Parameter

Parameter Description
pImage a parameter

Declaration

private static BufferedImage imageToBufferedImage(Image pImage) 

Method Source Code

//package com.java2s;
/**//w w  w  .  j a v  a 2  s  . co m
 * Copyright (c) 2013 M. Alexander Nugent Consulting <i@alexnugent.name>
 *
 * M. Alexander Nugent Consulting Research License Agreement
 * Non-Commercial Academic Use Only
 *
 * This Software is proprietary. By installing, copying, or otherwise using this
 * Software, you agree to be bound by the terms of this license. If you do not agree,
 * do not install, copy, or use the Software. The Software is protected by copyright
 * and other intellectual property laws.
 *
 * You may use the Software for non-commercial academic purpose, subject to the following
 * restrictions. You may copy and use the Software for peer-review and methods verification
 * only. You may not create derivative works of the Software. You may not use or distribute
 * the Software or any derivative works in any form for commercial or non-commercial purposes.
 *
 * Violators will be prosecuted to the full extent of the law.
 *
 * All rights reserved. No warranty, explicit or implicit, provided.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARR?ANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */

import java.awt.Graphics2D;
import java.awt.Image;

import java.awt.image.BufferedImage;

public class Main {
    /**
     * @param pImage
     * @return
     */
    private static BufferedImage imageToBufferedImage(Image pImage) {

        int w = pImage.getWidth(null);
        int h = pImage.getHeight(null);
        int type = BufferedImage.TYPE_INT_ARGB; // other options
        BufferedImage lBufferedImage = new BufferedImage(w, h, type);

        Graphics2D g2 = lBufferedImage.createGraphics();
        g2.drawImage(pImage, 0, 0, null);
        g2.dispose();
        return lBufferedImage;
    }
}

Related

  1. getScaledBufferedImage(Image icon, double scale)
  2. imageToBufferedImage(Image image)
  3. ImageToBufferedImage(Image image, int width, int height)
  4. imageToBufferedImage(Image img)
  5. imageToBufferedImage(Image img)
  6. imageToBufferedImage(Image src)
  7. makeRGBABufferedImageFromImage( Image image)
  8. toBufferedImage(Image i)
  9. toBufferedImage(Image image)