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

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

?? bmpreader.java

?? JavaExplorer是一個獨立于平臺的瀏覽器
?? JAVA
字號:
package javaexplorer.io.reader;import java.awt.*;import java.awt.image.*;import java.io.*;// This class provides a public static method that takes an InputStream// to a Windows .BMP file and converts it into an ImageProducer via// a MemoryImageSource.// You can fetch a .BMP through a URL with the following code:// URL url = new URL( <wherever your URL is> )// Image img = createImage(BMPReader.getBMPImage(url.openStream()));public class BMPReader extends Object {    // Constants indicating how the data is stored    public static final int BI_RGB = 0;    public static final int BI_RLE8 = 1;    public static final int BI_RLE4 = 2;    public static int is;    public static Image getImage(File file) {        Image img = null;        try {            ImageProducer ip = BMPReader.getBMPImage(new FileInputStream(file));            img = Toolkit.getDefaultToolkit().createImage(ip);        } catch (Exception e) {            javaexplorer.util.Log.addError(e);        }        return img;    }    public static Image getImage(byte[] buf) {        Image img = null;        try {            java.io.ByteArrayInputStream bais = new java.io.ByteArrayInputStream(buf);            ImageProducer ip = BMPReader.getBMPImage(bais);            img = Toolkit.getDefaultToolkit().createImage(ip);        } catch (Exception e) {            javaexplorer.util.Log.addError(e);        }        return img;    }    public static ImageProducer getBMPImage(InputStream stream)        throws IOException {        // The DataInputStream allows you to read in 16 and 32 bit numbers        DataInputStream in = new DataInputStream(stream);        // Verify that the header starts with 'BM'        if (in.read() != 'B') {            throw new IOException("Not a .BMP file");        }        if (in.read() != 'M') {            throw new IOException("Not a .BMP file");        }        // Get the total file size        int fileSize = intelInt(in.readInt());        // Skip the 2 16-bit reserved words        in.readUnsignedShort();        in.readUnsignedShort();        int bitmapOffset = intelInt(in.readInt());        int bitmapInfoSize = intelInt(in.readInt());        int width = intelInt(in.readInt());        int height = intelInt(in.readInt());        // Skip the 16-bit bitplane size        in.readUnsignedShort();        int bitCount = intelShort(in.readUnsignedShort());        int compressionType = intelInt(in.readInt());        int imageSize = intelInt(in.readInt());        is = imageSize;        // Skip pixels per meter        in.readInt();        in.readInt();        int colorsUsed = intelInt(in.readInt());        int colorsImportant = intelInt(in.readInt());        if (colorsUsed == 0) {            colorsUsed = 1 << bitCount;        }        // Create space for the pixels        int[] pixels = new int[width * height];        if (bitCount != 24) {            int[] colorTable = new int[colorsUsed];            // Read the bitmap's color table            for (int i = 0; i < colorsUsed; i++) {                //System.out.println(i + " ");                colorTable[i] = (intelInt(in.readInt()) & 0xffffff) +                    0xff000000;            }            // Read the pixels from the stream based on the compression type            if (compressionType == BI_RGB) {                readRGB(width, height, colorTable, bitCount, pixels, in);            } else if (compressionType == BI_RLE8) {                readRLE(width, height, colorTable, bitCount, pixels, in,                    imageSize, 8);            } else if (compressionType == BI_RLE4) {                readRLE(width, height, colorTable, bitCount, pixels, in,                    imageSize, 4);            }        } else {            readRGB24(width, height, pixels, in);        }        // Create a memory image source from the pixels        return new MemoryImageSource(width, height, pixels, 0, width);    }    // Reads in pixels in 24-bit format. There is no color table, and the    // pixels are stored in 3-byte pairs. Oddly, all windows bitmaps are    // stored upside-down - the bottom line is stored first.    protected static void readRGB24(int width, int height, int[] pixels,        DataInputStream in) throws IOException {        // Start storing at the bottom of the array        for (int h = height - 1; h >= 0; h--) {            int pos = h * width;            for (int w = 0; w < width; w++) {                // Read in the red, green, and blue components                int red = in.readUnsignedByte();                int green = in.readUnsignedByte();                int blue = in.readUnsignedByte();                // Turn the red, green, and blue values into an RGB color with                // an alpha value of 255 (fully opaque)                //pixels[pos++] = 0xff000000 + (red << 16) + (green << 8) + blue;                pixels[pos++] = 0xff000000 + red + (green << 8) + (blue << 16);            }            long off = (is / height) - (width * 3);            for (int j = 0; j < off; j++)                in.readUnsignedByte();        }    }    // readRGB reads in pixels values that are stored uncompressed.    // The bits represent indices into the color table.    protected static void readRGB(int width, int height, int[] colorTable,        int bitCount, int[] pixels, DataInputStream in)        throws IOException {        // How many pixels can be stored in a byte?        int pixelsPerByte = 8 / bitCount;        // A bit mask containing the number of bits in a pixel        int bitMask = (1 << bitCount) - 1;        // The shift values that will move each pixel to the far right        int[] bitShifts = new int[pixelsPerByte];        for (int i = 0; i < pixelsPerByte; i++) {            bitShifts[i] = 8 - ((i + 1) * bitCount);        }        int whichBit = 0;        // Read in the first byte        int currByte = in.read();        long off = (is - ((height * width) / pixelsPerByte)) / height;        //        System.out.println("is: " + is + " bitCount: " + bitCount + " off: " + off);        if ((off < 0) || (is == 0)) {            if ((bitCount == 8) && (height != width)) {                off = 3;            }        }        // Start at the bottom of the pixel array and work up        for (int h = height - 1; h >= 0; h--) {            int pos = h * width;            for (int w = 0; w < width; w++) {                // Get the next pixel from the current byte                try {                    pixels[pos] = colorTable[(currByte >> bitShifts[whichBit]) &                        bitMask];                } catch (ArrayIndexOutOfBoundsException ae) {                    //                  System.out.println("Array out of bounds, pos = " + pos);                    break;                }                pos++;                whichBit++;                // If the current bit position is past the number of pixels in                // a byte, we advance to the next byte                if (whichBit >= pixelsPerByte) {                    whichBit = 0;                    currByte = in.read();                }            }             // end for            //            System.out.println("height: " + height + " width: " + width + " is: " + is);            try {                for (int j = 0; j < off; j++)                    in.readUnsignedByte();            } catch (EOFException e) { /*System.out.println("Still something wrong");*/            }        }         // end for    }    // readRLE reads run-length encoded data in either RLE4 or RLE8 format.    protected static void readRLE(int width, int height, int[] colorTable,        int bitCount, int[] pixels, DataInputStream in, int imageSize,        int pixelSize) throws IOException {        int x = 0;        int y = height - 1;        // You already know how many bytes are in the image, so only go        // through that many.        for (int i = 0; i < imageSize; i++) {            // RLE encoding is defined by two bytes            int byte1 = in.read();            int byte2 = in.read();            i += 2;            // If byte 0 == 0, this is an escape code            if (byte1 == 0) {                // If escaped, byte 2 == 0 means you are at end of line                if (byte2 == 0) {                    x = 0;                    y--;                    // If escaped, byte 2 == 1 means end of bitmap                } else if (byte2 == 1) {                    return;                    // if escaped, byte 2 == 2 adjusts the current x and y by                    // an offset stored in the next two words                } else if (byte2 == 2) {                    int xoff = (char) intelShort(in.readUnsignedShort());                    i += 2;                    int yoff = (char) intelShort(in.readUnsignedShort());                    i += 2;                    x += xoff;                    y -= yoff;                    // If escaped, any other value for byte 2 is the number of bytes                    // that you should read as pixel values (these pixels are not                    // run-length encoded)                } else {                    int whichBit = 0;                    // Read in the next byte                    int currByte = in.read();                    i++;                    for (int j = 0; j < byte2; j++) {                        if (pixelSize == 4) {                            // The pixels are 4-bits, so half the time you shift the current byte                            // to the right as the pixel value                            if (whichBit == 0) {                                pixels[(y * width) + x] = colorTable[(currByte >> 4) &                                    0xf];                            } else {                                // The rest of the time, you mask out the upper 4 bits, save the pixel                                // value, then read in the next byte                                pixels[(y * width) + x] = colorTable[currByte &                                    0xf];                                currByte = in.read();                                i++;                            }                        } else {                            pixels[(y * width) + x] = colorTable[currByte];                            currByte = in.read();                            i++;                        }                        x++;                        if (x >= width) {                            x = 0;                            y--;                        }                    }                    // The pixels must be word-aligned, so if you read an uneven number of                    // bytes, read and ignore a byte to get aligned again.                    if ((byte2 & 1) == 1) {                        in.read();                        i++;                    }                }                // If the first byte was not 0, it is the number of pixels that                // are encoded by byte 2            } else {                for (int j = 0; j < byte1; j++) {                    if (pixelSize == 4) {                        // If j is odd, use the upper 4 bits                        if ((j & 1) == 0) {                            pixels[(y * width) + x] = colorTable[(byte2 >> 4) &                                0xf];                        } else {                            pixels[(y * width) + x + 1] = colorTable[byte2 &                                0xf];                        }                    } else {                        pixels[(y * width) + x + 1] = colorTable[byte2];                    }                    x++;                    if (x >= width) {                        x = 0;                        y--;                    }                }            }        }    }    // intelShort converts a 16-bit number stored in intel byte order into    // the local host format    protected static int intelShort(int i) {        return ((i >> 8) & 0xff) + ((i << 8) & 0xff00);    }    // intelInt converts a 32-bit number stored in intel byte order into    // the local host format    protected static int intelInt(int i) {        return ((i & 0xff) << 24) + ((i & 0xff00) << 8) +        ((i & 0xff0000) >> 8) + ((i >> 24) & 0xff);    }}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
精品乱人伦小说| 久久美女艺术照精彩视频福利播放| 欧美日韩美女一区二区| 欧美日韩国产一二三| 国产午夜精品久久| 日韩成人伦理电影在线观看| www.日本不卡| 精品久久久久久久久久久久久久久 | 在线视频综合导航| 国产日韩欧美不卡在线| 日本vs亚洲vs韩国一区三区| 91蜜桃婷婷狠狠久久综合9色| 久久综合五月天婷婷伊人| 丝袜国产日韩另类美女| 99麻豆久久久国产精品免费优播| 欧美mv和日韩mv国产网站| 五月婷婷另类国产| 色94色欧美sute亚洲线路一ni| 久久久.com| 久久99这里只有精品| 7777精品伊人久久久大香线蕉完整版 | 亚洲伊人色欲综合网| 99视频在线观看一区三区| 国产三级欧美三级日产三级99| 蜜桃久久久久久久| 91精品国产综合久久精品图片| 亚洲一区免费观看| 欧洲av一区二区嗯嗯嗯啊| 一区二区三区欧美视频| 91在线国产福利| 亚洲黄色小说网站| 91精彩视频在线| 一区二区三区四区在线播放| 91在线视频播放地址| 亚洲欧美激情一区二区| 中文字幕永久在线不卡| 狠狠色狠狠色合久久伊人| 欧美一级免费观看| 午夜伦欧美伦电影理论片| 91成人免费网站| 樱花影视一区二区| 欧美日韩视频第一区| 香港成人在线视频| 日韩欧美在线综合网| 久久福利资源站| 久久久久国产一区二区三区四区| 国产成人福利片| 亚洲欧美一区二区三区孕妇| 91丝袜呻吟高潮美腿白嫩在线观看| 亚洲视频一区在线观看| 在线视频国内一区二区| 日韩国产欧美视频| 国产片一区二区| 99精品视频在线观看| 性欧美大战久久久久久久久| 精品欧美一区二区久久| 成人一区二区三区中文字幕| 亚洲精选一二三| 91精品国产乱码| 国产一区二区免费视频| 亚洲视频一二区| 欧美色倩网站大全免费| 国产乱码精品一区二区三| 中文字幕一区二区视频| 91精品国产色综合久久不卡电影 | 99re6这里只有精品视频在线观看 99re8在线精品视频免费播放 | 国产无一区二区| 色综合天天综合| 青青草一区二区三区| 国产精品三级视频| 日韩免费看网站| 成人激情午夜影院| 日本 国产 欧美色综合| 最新日韩av在线| 欧美一区二区不卡视频| 91网站最新网址| 麻豆91在线播放免费| 亚洲日本免费电影| 精品1区2区在线观看| 欧美中文字幕不卡| 成人综合在线视频| 免费在线看成人av| 一区二区三区在线视频播放| 久久久综合视频| 欧美老肥妇做.爰bbww视频| 成人午夜视频网站| 麻豆一区二区三| 亚洲一区二区视频| 欧美国产一区二区在线观看| 日韩欧美在线网站| 欧美性猛交xxxxxx富婆| 成人综合在线观看| 国产最新精品免费| 日本免费新一区视频| 一区二区免费在线| 国产精品国产精品国产专区不蜜| 精品国产乱码久久久久久1区2区| 欧美日韩国产高清一区二区三区 | 欧美极品aⅴ影院| 日韩你懂的在线播放| 欧美人xxxx| 欧美日韩一区二区三区四区五区 | 日韩写真欧美这视频| 欧美日韩黄视频| 欧美亚洲国产一卡| 色哟哟精品一区| 91看片淫黄大片一级在线观看| 粉嫩欧美一区二区三区高清影视| 蜜桃av噜噜一区| 奇米综合一区二区三区精品视频| 亚洲a一区二区| 午夜视频在线观看一区| 亚洲不卡一区二区三区| 日韩在线观看一区二区| 香蕉成人啪国产精品视频综合网| 亚洲高清中文字幕| 偷拍亚洲欧洲综合| 五月婷婷欧美视频| 免费在线观看一区二区三区| 日韩精品免费专区| 捆绑调教美女网站视频一区| 九色综合国产一区二区三区| 精品一区二区三区的国产在线播放| 久久精品国产一区二区| 国产一区二区三区香蕉| 国产91精品一区二区| 成人黄色片在线观看| 不卡一区二区三区四区| 日本道免费精品一区二区三区| 91香蕉视频黄| 欧美亚洲尤物久久| 337p亚洲精品色噜噜噜| 久久在线免费观看| 中文字幕精品—区二区四季| 亚洲男人天堂av网| 视频一区二区中文字幕| 精品一区二区国语对白| 粉嫩在线一区二区三区视频| 在线一区二区视频| 日韩三级伦理片妻子的秘密按摩| 精品国免费一区二区三区| 国产精品国产三级国产aⅴ无密码 国产精品国产三级国产aⅴ原创 | 亚洲欧美日韩国产综合在线| 午夜一区二区三区视频| 国产一区二区三区精品欧美日韩一区二区三区 | 日韩黄色在线观看| 国产传媒久久文化传媒| 色噜噜久久综合| 日韩欧美国产一区二区三区| 国产精品久久久久aaaa| 日韩精品福利网| 成人免费看片app下载| 欧美日韩一区二区在线视频| 久久久精品国产99久久精品芒果| 亚洲欧美激情插| 九九久久精品视频| 欧美午夜精品一区| 久久人人超碰精品| 亚洲va中文字幕| 国产盗摄视频一区二区三区| 欧美欧美午夜aⅴ在线观看| 日本一区二区三区四区| 日本午夜一区二区| aaa欧美日韩| 久久久国产综合精品女国产盗摄| 亚洲资源在线观看| 国产成人综合网站| 日韩欧美高清dvd碟片| 亚洲精品中文字幕在线观看| 国产精品中文字幕日韩精品| 国产福利电影一区二区三区| 欧美日韩一级片网站| 日韩美女啊v在线免费观看| 韩国欧美国产1区| 欧洲一区二区三区免费视频| 国产精品视频麻豆| 精品一区二区精品| 91精品国产色综合久久ai换脸| 亚洲精品乱码久久久久久久久| 国产成人欧美日韩在线电影| 日韩精品一区二区三区在线| 亚洲一线二线三线久久久| 91免费精品国自产拍在线不卡| 久久精品无码一区二区三区| 日产国产高清一区二区三区| 在线免费一区三区| 亚洲日本乱码在线观看| 不卡的av网站| 欧美激情一区在线| 国产麻豆一精品一av一免费| 欧美精品一区男女天堂| 蜜乳av一区二区三区| 宅男噜噜噜66一区二区66| 亚洲午夜久久久久中文字幕久| 在线视频一区二区三区| 亚洲欧美日韩久久| 91福利视频久久久久| 亚洲一二三四在线观看| 欧美熟乱第一页| 首页国产丝袜综合|