jdk/makefiles/sun/awt/X11/ToBin.java
author ohair
Fri, 26 Oct 2012 14:23:29 -0700
changeset 14231 a0c23c1c010f
permissions -rw-r--r--
8000992: Update new build-infra makefiles Summary: Build-infra project integration. Multiple authors on this work: erikj and ihse primarily, also changes from ohair, tbell, and dholmes. Special credit to ohstrom for his smartjavac work. Reviewed-by: erikj, ihse, dholmes, tbell
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
14231
a0c23c1c010f 8000992: Update new build-infra makefiles
ohair
parents:
diff changeset
     1
/*
a0c23c1c010f 8000992: Update new build-infra makefiles
ohair
parents:
diff changeset
     2
 * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
a0c23c1c010f 8000992: Update new build-infra makefiles
ohair
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a0c23c1c010f 8000992: Update new build-infra makefiles
ohair
parents:
diff changeset
     4
 *
a0c23c1c010f 8000992: Update new build-infra makefiles
ohair
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
a0c23c1c010f 8000992: Update new build-infra makefiles
ohair
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
a0c23c1c010f 8000992: Update new build-infra makefiles
ohair
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
a0c23c1c010f 8000992: Update new build-infra makefiles
ohair
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
a0c23c1c010f 8000992: Update new build-infra makefiles
ohair
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
a0c23c1c010f 8000992: Update new build-infra makefiles
ohair
parents:
diff changeset
    10
 *
a0c23c1c010f 8000992: Update new build-infra makefiles
ohair
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
a0c23c1c010f 8000992: Update new build-infra makefiles
ohair
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a0c23c1c010f 8000992: Update new build-infra makefiles
ohair
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
a0c23c1c010f 8000992: Update new build-infra makefiles
ohair
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
a0c23c1c010f 8000992: Update new build-infra makefiles
ohair
parents:
diff changeset
    15
 * accompanied this code).
a0c23c1c010f 8000992: Update new build-infra makefiles
ohair
parents:
diff changeset
    16
 *
a0c23c1c010f 8000992: Update new build-infra makefiles
ohair
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
a0c23c1c010f 8000992: Update new build-infra makefiles
ohair
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
a0c23c1c010f 8000992: Update new build-infra makefiles
ohair
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a0c23c1c010f 8000992: Update new build-infra makefiles
ohair
parents:
diff changeset
    20
 *
a0c23c1c010f 8000992: Update new build-infra makefiles
ohair
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
a0c23c1c010f 8000992: Update new build-infra makefiles
ohair
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
a0c23c1c010f 8000992: Update new build-infra makefiles
ohair
parents:
diff changeset
    23
 * questions.
a0c23c1c010f 8000992: Update new build-infra makefiles
ohair
parents:
diff changeset
    24
 */
a0c23c1c010f 8000992: Update new build-infra makefiles
ohair
parents:
diff changeset
    25
a0c23c1c010f 8000992: Update new build-infra makefiles
ohair
parents:
diff changeset
    26
package sun.awt.X11;
a0c23c1c010f 8000992: Update new build-infra makefiles
ohair
parents:
diff changeset
    27
a0c23c1c010f 8000992: Update new build-infra makefiles
ohair
parents:
diff changeset
    28
import java.io.*;
a0c23c1c010f 8000992: Update new build-infra makefiles
ohair
parents:
diff changeset
    29
import java.awt.image.*;
a0c23c1c010f 8000992: Update new build-infra makefiles
ohair
parents:
diff changeset
    30
import javax.imageio.*;
a0c23c1c010f 8000992: Update new build-infra makefiles
ohair
parents:
diff changeset
    31
import java.awt.*;
a0c23c1c010f 8000992: Update new build-infra makefiles
ohair
parents:
diff changeset
    32
a0c23c1c010f 8000992: Update new build-infra makefiles
ohair
parents:
diff changeset
    33
public class ToBin {
a0c23c1c010f 8000992: Update new build-infra makefiles
ohair
parents:
diff changeset
    34
    public static void main(String[] args) throws Exception {
a0c23c1c010f 8000992: Update new build-infra makefiles
ohair
parents:
diff changeset
    35
        BufferedImage im = ImageIO.read(System.in);
a0c23c1c010f 8000992: Update new build-infra makefiles
ohair
parents:
diff changeset
    36
        BufferedImage bi = null;
a0c23c1c010f 8000992: Update new build-infra makefiles
ohair
parents:
diff changeset
    37
        int iconWidth = im.getWidth(null);
a0c23c1c010f 8000992: Update new build-infra makefiles
ohair
parents:
diff changeset
    38
        int iconHeight = im.getHeight(null);
a0c23c1c010f 8000992: Update new build-infra makefiles
ohair
parents:
diff changeset
    39
        if (im != null && iconHeight != 0 &&  iconWidth != 0) {
a0c23c1c010f 8000992: Update new build-infra makefiles
ohair
parents:
diff changeset
    40
            bi = new BufferedImage(iconWidth, iconHeight, BufferedImage.TYPE_INT_ARGB);
a0c23c1c010f 8000992: Update new build-infra makefiles
ohair
parents:
diff changeset
    41
            Graphics g = bi.getGraphics();
a0c23c1c010f 8000992: Update new build-infra makefiles
ohair
parents:
diff changeset
    42
            try {
a0c23c1c010f 8000992: Update new build-infra makefiles
ohair
parents:
diff changeset
    43
                g.drawImage(im, 0, 0, iconWidth, iconHeight, null);
a0c23c1c010f 8000992: Update new build-infra makefiles
ohair
parents:
diff changeset
    44
            } finally {
a0c23c1c010f 8000992: Update new build-infra makefiles
ohair
parents:
diff changeset
    45
                g.dispose();
a0c23c1c010f 8000992: Update new build-infra makefiles
ohair
parents:
diff changeset
    46
            }
a0c23c1c010f 8000992: Update new build-infra makefiles
ohair
parents:
diff changeset
    47
        }
a0c23c1c010f 8000992: Update new build-infra makefiles
ohair
parents:
diff changeset
    48
        DataBuffer srcBuf = bi.getData().getDataBuffer();
a0c23c1c010f 8000992: Update new build-infra makefiles
ohair
parents:
diff changeset
    49
        int[] buf = ((DataBufferInt)srcBuf).getData();
a0c23c1c010f 8000992: Update new build-infra makefiles
ohair
parents:
diff changeset
    50
        System.out.print(iconWidth + ",");
a0c23c1c010f 8000992: Update new build-infra makefiles
ohair
parents:
diff changeset
    51
        System.out.println(iconHeight + ",");
a0c23c1c010f 8000992: Update new build-infra makefiles
ohair
parents:
diff changeset
    52
        for (int i = 0; i < buf.length; i++) {
a0c23c1c010f 8000992: Update new build-infra makefiles
ohair
parents:
diff changeset
    53
            System.out.print("0x" + Integer.toHexString(buf[i]) + ", ");
a0c23c1c010f 8000992: Update new build-infra makefiles
ohair
parents:
diff changeset
    54
            if (i % 10 == 0) {
a0c23c1c010f 8000992: Update new build-infra makefiles
ohair
parents:
diff changeset
    55
                System.out.println();
a0c23c1c010f 8000992: Update new build-infra makefiles
ohair
parents:
diff changeset
    56
            }
a0c23c1c010f 8000992: Update new build-infra makefiles
ohair
parents:
diff changeset
    57
        }
a0c23c1c010f 8000992: Update new build-infra makefiles
ohair
parents:
diff changeset
    58
    }
a0c23c1c010f 8000992: Update new build-infra makefiles
ohair
parents:
diff changeset
    59
}