亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? bmploader.java

?? java圖像處理
?? JAVA
字號:
//
//This code was taken and cleaned up from a
//Javaworld tips and tricks column
//

import java.awt.Image;
import java.awt.Toolkit;
import java.awt.image.MemoryImageSource;
import java.io.FileInputStream;
import java.io.IOException;

import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JScrollPane;

//
//really just a collection of methods to read a BMP file
//

public class BMPLoader

{

    // build an int from a byte array - convert little to big endian
    public static int constructInt(byte[] in, int offset) {

        int ret = ((int) in[offset + 3] & 0xff);

        ret = (ret << 8) | ((int) in[offset + 2] & 0xff);

        ret = (ret << 8) | ((int) in[offset + 1] & 0xff);

        ret = (ret << 8) | ((int) in[offset + 0] & 0xff);

        return (ret);

    }

    // build an int from a byte array - convert little to big endian
    // set high order bytes to 0xfff
    public static int constructInt3(byte[] in, int offset) {

        int ret = 0xff;

        ret = (ret << 8) | ((int) in[offset + 2] & 0xff);

        ret = (ret << 8) | ((int) in[offset + 1] & 0xff);

        ret = (ret << 8) | ((int) in[offset + 0] & 0xff);

        return (ret);

    }

    // build an int from a byte array - convert little to big endian
    public static long constructLong(byte[] in, int offset) {

        long ret = ((long) in[offset + 7] & 0xff);

        ret |= (ret << 8) | ((long) in[offset + 6] & 0xff);

        ret |= (ret << 8) | ((long) in[offset + 5] & 0xff);

        ret |= (ret << 8) | ((long) in[offset + 4] & 0xff);

        ret |= (ret << 8) | ((long) in[offset + 3] & 0xff);

        ret |= (ret << 8) | ((long) in[offset + 2] & 0xff);

        ret |= (ret << 8) | ((long) in[offset + 1] & 0xff);

        ret |= (ret << 8) | ((long) in[offset + 0] & 0xff);

        return (ret);

    }

    // build an double from a byte array - convert little to big endian
    public static double constructDouble(byte[] in, int offset) {

        long ret = constructLong(in, offset);

        return (Double.longBitsToDouble(ret));

    }

    // build an short from a byte array - convert little to big endian
    public static short constructShort(byte[] in, int offset) {

        short ret = (short) ((short) in[offset + 1] & 0xff);

        ret = (short) ((ret << 8) | (short) ((short) in[offset + 0] & 0xff));

        return (ret);

    }

    // internal class representing a bitmap header structure
    // with code to read it from a file
    static class BitmapHeader {

        public int nsize;

        public int nbisize;

        public int nwidth;

        public int nheight;

        public int nplanes;

        public int nbitcount;

        public int ncompression;

        public int nsizeimage;

        public int nxpm;

        public int nypm;

        public int nclrused;

        public int nclrimp;

        // read in the bitmap header
        public void read(FileInputStream fs) throws IOException

        {

            final int bflen = 14; // 14 byte BITMAPFILEHEADER

            byte bf[] = new byte[bflen];

            fs.read(bf, 0, bflen);

            final int bilen = 40; // 40-byte BITMAPINFOHEADER

            byte bi[] = new byte[bilen];

            fs.read(bi, 0, bilen);

            // Interperet data.
            nsize = constructInt(bf, 2);

            //  System.out.println("File type is :"+(char)bf[0]+(char)bf[1]);
            //  System.out.println("Size of file is :"+nsize);

            nbisize = constructInt(bi, 2);

            //   System.out.println("Size of bitmapinfoheader is :"+nbisize);

            nwidth = constructInt(bi, 4);

            //   System.out.println("Width is :"+nwidth);

            nheight = constructInt(bi, 8);

            //  System.out.println("Height is :"+nheight);

            nplanes = constructShort(bi, 12); //(((int)bi[13]&0xff)<<8) |
            // (int)bi[12]&0xff;

            //  System.out.println("Planes is :"+nplanes);

            nbitcount = constructShort(bi, 14); //(((int)bi[15]&0xff)<<8) |
            // (int)bi[14]&0xff;

            //  System.out.println("BitCount is :"+nbitcount);

            // Look for non-zero values to indicate compression
            ncompression = constructInt(bi, 16);

            //  System.out.println("Compression is :"+ncompression);

            nsizeimage = constructInt(bi, 20);

            //  System.out.println("SizeImage is :"+nsizeimage);

            nxpm = constructInt(bi, 24);

            // System.out.println("X-Pixels per meter is :"+nxpm);

            nypm = constructInt(bi, 28);

            // System.out.println("Y-Pixels per meter is :"+nypm);

            nclrused = constructInt(bi, 32);

            //  System.out.println("Colors used are :"+nclrused);

            nclrimp = constructInt(bi, 36);

            //  System.out.println("Colors important are :"+nclrimp);

        }

    }

    public static Image read(FileInputStream fs)

    {

        try {

            BitmapHeader bh = new BitmapHeader();

            bh.read(fs);

            if (bh.nbitcount == 24)

                return (readMap24(fs, bh));

            if (bh.nbitcount == 32)

                return (readMap32(fs, bh));

            if (bh.nbitcount == 8)

                return (readMap8(fs, bh));

            fs.close();

        } catch (IOException e) {

            // System.out.println("Caught exception in loadbitmap!");
        }

        return (null);

    }

    /**
     *
     * readMap24 internal routine to read the bytes in a 24 bit bitmap
     *
     *
     *
     * Arguments:
     *
     * fs - file stream
     *
     * bh - header struct
     *
     * Returns:
     *
     * Image Object, be sure to check for (Image)null !!!!
     *
     *
     * 
     */
    protected static Image readMap32(FileInputStream fs, BitmapHeader bh)
            throws IOException

    {

        Image image;

        // No Palatte data for 24-bit format but scan lines are

        // padded out to even 4-byte boundaries.

        int xwidth = bh.nsizeimage / bh.nheight;

        int ndata[] = new int[bh.nheight * bh.nwidth];

        byte brgb[] = new byte[bh.nwidth * 4 * bh.nheight];

        fs.read(brgb, 0, bh.nwidth * 4 * bh.nheight);

        int nindex = 0;

        for (int j = 0; j < bh.nheight; j++)

        {

            for (int i = 0; i < bh.nwidth; i++)

            {

                ndata[bh.nwidth * (bh.nheight - j - 1) + i] = constructInt3(
                        brgb, nindex);

                nindex += 4;

            }

        }

        image = Toolkit.getDefaultToolkit().createImage

        (new MemoryImageSource(bh.nwidth, bh.nheight,

        ndata, 0, bh.nwidth));

        fs.close();

        return (image);

    }

    /**
     *
     * readMap24 internal routine to read the bytes in a 24 bit bitmap
     *
     *
     *
     * Arguments:
     *
     * fs - file stream
     *
     * bh - header struct
     *
     * Returns:
     *
     * Image Object, be sure to check for (Image)null !!!!
     *
     *
     * 
     */
    protected static Image readMap24(FileInputStream fs, BitmapHeader bh)
            throws IOException

    {

        Image image;

        // No Palatte data for 24-bit format but scan lines are

        // padded out to even 4-byte boundaries.

        int npad = (bh.nsizeimage / bh.nheight) - bh.nwidth * 3;

        int ndata[] = new int[bh.nheight * bh.nwidth];

        byte brgb[] = new byte[(bh.nwidth + npad) * 3 * bh.nheight];

        fs.read(brgb, 0, (bh.nwidth + npad) * 3 * bh.nheight);

        int nindex = 0;

        for (int j = 0; j < bh.nheight; j++)

        {

            for (int i = 0; i < bh.nwidth; i++)

            {

                ndata[bh.nwidth * (bh.nheight - j - 1) + i] = constructInt3(
                        brgb, nindex);

                nindex += 3;

            }

            nindex += npad;

        }

        image = Toolkit.getDefaultToolkit().createImage

        (new MemoryImageSource(bh.nwidth, bh.nheight,

        ndata, 0, bh.nwidth));

        fs.close();

        return (image);

    }

    /**
     *
     * readMap8 internal routine to read the bytes in a 8 bit bitmap
     *
     *
     *
     * Arguments:
     *
     * fs - file stream
     *
     * bh - header struct
     *
     * Returns:
     *
     * Image Object, be sure to check for (Image)null !!!!
     *
     *
     * 
     */
    protected static Image readMap8(FileInputStream fs, BitmapHeader bh)
            throws IOException

    {

        Image image;

        // Have to determine the number of colors, the clrsused

        // parameter is dominant if it is greater than zero. If

        // zero, calculate colors based on bitsperpixel.

        int nNumColors = 0;

        if (bh.nclrused > 0)

        {

            nNumColors = bh.nclrused;

        }

        else

        {

            nNumColors = (1 & 0xff) << bh.nbitcount;

        }

        //     System.out.println("The number of Colors is"+nNumColors);

        // Some bitmaps do not have the sizeimage field calculated

        // Ferret out these cases and fix 'em.

        if (bh.nsizeimage == 0)

        {

            bh.nsizeimage = ((((bh.nwidth * bh.nbitcount) + 31) & ~31) >> 3);

            bh.nsizeimage *= bh.nheight;

            //          System.out.println("nsizeimage (backup) is"+nsizeimage);

        }

        // Read the palatte colors.

        int npalette[] = new int[nNumColors];

        byte bpalette[] = new byte[nNumColors * 4];

        fs.read(bpalette, 0, nNumColors * 4);

        int nindex8 = 0;

        for (int n = 0; n < nNumColors; n++)

        {

            npalette[n] = constructInt3(bpalette, nindex8);

            nindex8 += 4;

        }

        // Read the image data (actually indices into the palette)

        // Scan lines are still padded out to even 4-byte

        // boundaries.

        int npad8 = (bh.nsizeimage / bh.nheight) - bh.nwidth;

        //    System.out.println("nPad is:"+npad8);

        int ndata8[] = new int[bh.nwidth * bh.nheight];

        byte bdata[] = new byte[(bh.nwidth + npad8) * bh.nheight];

        fs.read(bdata, 0, (bh.nwidth + npad8) * bh.nheight);

        nindex8 = 0;

        for (int j8 = 0; j8 < bh.nheight; j8++)

        {

            for (int i8 = 0; i8 < bh.nwidth; i8++)

            {

                ndata8[bh.nwidth * (bh.nheight - j8 - 1) + i8] =

                npalette[((int) bdata[nindex8] & 0xff)];

                nindex8++;

            }

            nindex8 += npad8;

        }

        image = Toolkit.getDefaultToolkit().createImage

        (new MemoryImageSource(bh.nwidth, bh.nheight,

        ndata8, 0, bh.nwidth));

        return (image);

    }

    /**
     *
     * load method - see read for details
     *
     *
     *
     * Arguments:
     *
     * sdir and sfile are the result of the FileDialog()
     *
     * getDirectory() and getFile() methods.
     *
     *
     *
     * Returns:
     *
     * Image Object, be sure to check for (Image)null !!!!
     *
     *
     * 
     */
    public static Image load(String sdir, String sfile) {

        return (load(sdir + sfile));

    }

    /**
     *
     * load method - see read for details
     *
     *
     *
     * Arguments:
     *
     * sdir - full path name
     *
     *
     *
     * Returns:
     *
     * Image Object, be sure to check for (Image)null !!!!
     *
     *
     * 
     */
    public static Image load(String sdir)

    {

        try

        {

            FileInputStream fs = new FileInputStream(sdir);

            return (read(fs));

        }

        catch (IOException ex) {

            return (null);

        }

    }

    public static void main(String[] args) throws IOException

    {

        if (args.length == 0) {

            System.out.println("Usage >java BMPLoader ImageFile.bmp");

            System.exit(0);

        }

        FileInputStream in = new FileInputStream(args[0]);

        Image TheImage = read(in);

        JFrame TheFrame = new JFrame(args[0]);

        JLabel TheLabel = new JLabel(new ImageIcon(TheImage));

        TheFrame.getContentPane().add(new JScrollPane(TheLabel));

        TheFrame.setSize(300, 300);

        TheFrame.setVisible(true);

    }
    //end class BMPLoader
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
石原莉奈在线亚洲三区| 国产成人精品免费一区二区| 亚洲午夜精品在线| 亚洲欧美另类久久久精品| 国产精品久久久久久亚洲伦| 中国av一区二区三区| 欧美高清在线精品一区| 国产精品久线观看视频| 亚洲视频一区二区在线| 亚洲素人一区二区| 依依成人综合视频| 亚洲国产你懂的| 日韩激情视频在线观看| 日本欧美大码aⅴ在线播放| 免费人成精品欧美精品| 蜜臀久久久久久久| 激情欧美日韩一区二区| 国产成人av电影在线观看| 国产成人精品亚洲午夜麻豆| 成人精品gif动图一区| 91丨porny丨蝌蚪视频| 色狠狠色噜噜噜综合网| 欧美夫妻性生活| 欧美成人免费网站| 欧美极品另类videosde| 亚洲视频一二区| 日日噜噜夜夜狠狠视频欧美人| 美女视频黄久久| 国产高清视频一区| 色狠狠综合天天综合综合| 69精品人人人人| 久久久久久麻豆| 亚洲精品亚洲人成人网在线播放| 亚洲午夜一二三区视频| 极品销魂美女一区二区三区| 成人免费的视频| 欧美色窝79yyyycom| 欧美岛国在线观看| 18欧美乱大交hd1984| 亚洲成a人片综合在线| 国产美女精品一区二区三区| 91免费小视频| 日韩欧美国产一区二区三区 | 久久久久国产精品厨房| 国产精品久久久一区麻豆最新章节| 北条麻妃国产九九精品视频| 91亚洲精品一区二区乱码| 制服丝袜亚洲色图| 国产欧美精品一区二区色综合| 一级女性全黄久久生活片免费| 日韩高清一区在线| www.欧美亚洲| 8x福利精品第一导航| 欧美国产国产综合| 欧美aaa在线| 99免费精品在线观看| 欧美一级二级在线观看| 国产精品精品国产色婷婷| 首页欧美精品中文字幕| 不卡影院免费观看| 日韩欧美亚洲一区二区| 一区二区在线免费| 国产激情偷乱视频一区二区三区 | 国产精品欧美久久久久一区二区| 亚洲五月六月丁香激情| 国产成人8x视频一区二区 | 亚洲成精国产精品女| 国产精品888| 91精品国产福利在线观看| 日韩理论电影院| 国产精品一卡二卡在线观看| 欧美一区二区三区四区五区| 亚洲精品视频免费观看| 大胆亚洲人体视频| 亚洲精品一区二区精华| 天天综合色天天| 色狠狠一区二区| 自拍偷在线精品自拍偷无码专区 | 91亚洲精品久久久蜜桃网站| 欧美精品一区二区三区蜜桃视频| 亚洲成人免费视| 91久久精品午夜一区二区| 国产女主播一区| 国产一区视频在线看| 91精品国产一区二区| 亚洲一区二区成人在线观看| 99精品久久99久久久久| 国产人伦精品一区二区| 久久国产精品区| 日韩欧美国产综合| 日本在线播放一区二区三区| 欧美中文字幕一区| 一区二区三区久久久| 91免费在线视频观看| 国产精品久久久久久久久图文区 | 成人毛片视频在线观看| 精品国产乱码久久久久久老虎| 免费在线欧美视频| 91精品国产综合久久小美女| 欧美日韩中文国产| 亚洲国产日韩综合久久精品| 91麻豆高清视频| 亚洲欧美另类久久久精品| 色综合久久中文综合久久97 | 99re这里只有精品视频首页| 国产欧美精品区一区二区三区 | 91精品1区2区| 一区二区三区资源| 在线免费观看视频一区| 亚洲一区二区三区四区中文字幕| 91九色02白丝porn| 亚洲444eee在线观看| 欧美精品九九99久久| 免费在线观看成人| 久久久午夜电影| 国产成人在线视频免费播放| 国产日韩精品一区二区三区 | 国产精品毛片无遮挡高清| 粉嫩高潮美女一区二区三区| 国产精品午夜久久| 91看片淫黄大片一级| 亚洲成人综合网站| 日韩一区二区三区在线| 国产伦精一区二区三区| 中文字幕一区二区三区在线播放| 91麻豆精品一区二区三区| 亚洲国产乱码最新视频| 日韩一区二区在线观看视频| 国产精品伊人色| 亚洲日本成人在线观看| 欧美精品日韩综合在线| 狠狠色综合播放一区二区| 中国色在线观看另类| 欧美日韩在线播放| 精品一区二区免费在线观看| 国产偷v国产偷v亚洲高清| 色美美综合视频| 久草中文综合在线| 国产精品家庭影院| 欧美电影在哪看比较好| 国产乱人伦偷精品视频免下载| |精品福利一区二区三区| 欧美日本在线播放| 国产成人超碰人人澡人人澡| 亚洲午夜精品网| 26uuu国产日韩综合| 91蝌蚪porny成人天涯| 免费成人av在线播放| 最新中文字幕一区二区三区| 91精品国产手机| 成人的网站免费观看| 美女免费视频一区二区| 国产精品麻豆视频| 欧美一区二区三区啪啪| 成人午夜激情在线| 日本美女视频一区二区| 中文字幕一区二区在线播放| 欧美一区二区三区在线观看 | 91精品视频网| 不卡大黄网站免费看| 日韩精品亚洲一区| 国产成人精品三级| 秋霞电影网一区二区| 成人免费一区二区三区在线观看| 欧美xxxxxxxx| 欧美在线free| 波多野结衣的一区二区三区| 奇米影视7777精品一区二区| 亚洲天堂av老司机| 久久久国产午夜精品| 欧美精品九九99久久| 日本道免费精品一区二区三区| 国产精品综合久久| 毛片av一区二区| 亚洲一卡二卡三卡四卡五卡| 国产精品日日摸夜夜摸av| 日韩一区二区三区免费观看| 色www精品视频在线观看| 成人国产视频在线观看| 久久精品国产在热久久| 亚洲二区视频在线| 亚洲欧美另类在线| 国产精品福利一区二区三区| 26uuu亚洲综合色| 日韩一区二区三区视频在线| 欧美日韩黄色一区二区| 日本高清不卡在线观看| 91在线视频官网| 成人白浆超碰人人人人| 国产福利精品一区二区| 捆绑调教美女网站视频一区| 热久久免费视频| 午夜电影久久久| 亚洲va欧美va人人爽| 有码一区二区三区| 亚洲日本乱码在线观看| 亚洲色图一区二区| 亚洲色图欧美在线| 一区二区在线看| 亚洲色图20p|