home *** CD-ROM | disk | FTP | other *** search
- package com.sfs.iavazip.viewer;
-
- import java.awt.Image;
- import java.io.IOException;
-
- public class ImageLoaderBMP extends ImageLoader implements ProgressStatus {
- private int[] bmiColors;
- // $FF: renamed from: zl int
- private int field_0;
- private int biPlanes;
- private int biBitCount;
- private int colNum;
- private int redColor15 = 31744;
- private int greenColor15 = 992;
- private int blueColor15 = 31;
- private int redColor24 = 16711680;
- private int greenColor24 = 65280;
- private int blueColor24 = 255;
- private int orientation;
- private int pixels;
- private int framePtr;
- private int cachePtr;
- private int red;
- private int green;
- private int blue;
- private int col;
- private int cacheStep;
- private int stepFrameCol;
- private int stepFrameRow;
- private int pixelCt;
- private int pixel;
- private int lastFramePos;
- private int alpha;
- private int fileLength;
- private int RLEtype;
- private int RLElength;
- private int RLEpause;
- private int padding;
- private int scanLineSize;
- private int actLine;
- private int lastPercent;
- private int actPercent;
- private String bfType;
- private long bfSize;
- private long bfOffBits;
- private long biSize;
- private long biWidth;
- private long biHeight;
- private long biCompression;
- private long biSizeImage;
- private long biClrUsed;
- private long biClrImportant;
- private byte[] cache;
- private boolean loaded;
- private boolean RLEencoded;
-
- protected void loadPicture() throws IOException {
- int var1 = 0;
- if (this.biCompression != 0L) {
- this.RLEencoded = true;
- }
-
- if (this.biBitCount < 24) {
- if (this.biClrUsed > 0L) {
- this.colNum = (int)this.biClrUsed;
- }
-
- this.bmiColors = new int[this.colNum];
-
- for(this.field_0 = 0; this.field_0 < this.colNum; ++this.field_0) {
- this.blue = super.imageFile.readByte() & 255;
- this.green = super.imageFile.readByte() & 255;
- this.red = super.imageFile.readByte() & 255;
- this.bmiColors[this.field_0] = this.red * 65536 + this.green * 256 + this.blue;
- super.imageFile.skipBytes(1);
- }
- }
-
- this.scanLineSize = (int)((this.biWidth * (long)this.biBitCount + 31L) / 32L) * 4;
- if (this.biSizeImage != 0L) {
- var1 = (int)this.biSizeImage;
- } else {
- var1 = (int)((long)this.scanLineSize * this.biHeight);
- }
-
- this.pixels = (int)(this.biWidth * this.biHeight);
- this.cache = super.imageFile.readBytes(var1, this);
- ((ImageLoader)this).print("bytes in the frame's buffer: " + super.frameBuffer.length);
- ((ImageLoader)this).print("bytes in cache: " + this.cache.length);
- ((ImageLoader)this).print("pixels: " + this.pixels);
- this.cachePtr = 0;
- this.stepFrameCol = 1;
- this.stepFrameRow = -(2 * super.xRes);
- this.framePtr = (super.yRes - 1) * super.xRes;
- this.pixelCt = 0;
- this.RLEpause = 0;
- this.RLElength = 1;
- if (this.biBitCount == 8) {
- this.decodeCMAP();
- }
-
- if (this.biBitCount == 24) {
- this.decodeTC();
- }
-
- super.imageFile.close();
- super.imageLoaded = true;
- this.cache = null;
- this.bmiColors = null;
- System.gc();
- }
-
- private void decodeCMAP() throws IOException {
- int var3 = 0;
- int var4 = (int)this.biWidth;
- int var5 = var4 / 4;
- int var6 = 0;
- int var7 = var4 - var5 * 4;
- if (var7 > 0) {
- var7 = (var5 + 1) * 4 - var4;
- }
-
- if (!this.RLEencoded) {
- ((ImageLoader)this).print("8-bit BMP image with palette, not encoded");
-
- for(; this.pixelCt < this.pixels; ++this.pixelCt) {
- this.pixel = this.cache[this.cachePtr++] & 255;
- super.frameBuffer[this.framePtr++] = this.bmiColors[this.pixel];
- ++this.col;
- if (this.col == super.xRes) {
- this.framePtr += this.stepFrameRow;
- this.col = 0;
- this.cachePtr += var7;
- }
- }
-
- ((ImageLoader)this).print("decoding ended");
- } else {
- this.lastFramePos = this.framePtr;
- this.stepFrameRow = 0 - super.xRes;
- ((ImageLoader)this).print("8-bit BMP image with palette, RLE encoded");
-
- while(this.pixelCt < this.pixels) {
- var3 = (boolean)0;
- this.RLElength = this.cache[this.cachePtr++] & 255;
- if (this.RLElength > 0) {
- this.pixel = this.cache[this.cachePtr++] & 255;
- var6 = this.bmiColors[this.pixel];
-
- for(this.field_0 = 0; this.field_0 < this.RLElength; ++this.field_0) {
- super.frameBuffer[this.framePtr++] = var6;
- ++this.pixelCt;
- }
- } else {
- this.RLEtype = this.cache[this.cachePtr++] & 255;
- if (this.RLEtype == 0) {
- this.newLine();
- } else {
- if (this.RLEtype == 1) {
- return;
- }
-
- if (this.RLEtype == 2) {
- int var1 = this.cache[this.cachePtr++] & 255;
- int var2 = this.cache[this.cachePtr++] & 255;
- ((ImageLoader)this).print("delta xOff: " + var1 + " yoff: " + var2);
- if (var2 > 0) {
- for(this.field_0 = 0; this.field_0 < var2; ++this.field_0) {
- this.framePtr -= super.xRes;
- this.pixelCt += super.xRes;
- }
- }
-
- if (var1 > 0) {
- this.framePtr += var1;
- this.col += var1;
- this.pixelCt += var1;
- }
- } else if (this.RLEtype <= 2) {
- ((ImageLoader)this).print("RLEtype strange: " + this.RLEtype);
- } else {
- this.RLElength = this.RLEtype;
- var3 = this.RLElength / 2;
- var3 *= 2;
- var3 = this.RLElength - var3;
-
- for(this.field_0 = 0; this.field_0 < this.RLElength; ++this.field_0) {
- this.pixel = this.cache[this.cachePtr++] & 255;
- super.frameBuffer[this.framePtr++] = this.bmiColors[this.pixel];
- ++this.pixelCt;
- }
-
- this.cachePtr += var3;
- }
- }
- }
- }
-
- }
- }
-
- private final void newLine() {
- this.lastFramePos += this.stepFrameRow;
- this.framePtr = this.lastFramePos;
- this.col = 0;
- this.cachePtr += this.padding;
- }
-
- public void imageLoaded(int var1, Image var2, String var3) {
- }
-
- public String getInfo() {
- return "";
- }
-
- protected void readHeader() throws IOException {
- ((ImageLoader)this).print(this.getInfo() + " running");
- super.imageFile.setIntelSwitch(true);
- this.bfType = super.imageFile.readString(2);
- if (!this.bfType.equals("BM")) {
- }
-
- this.bfSize = super.imageFile.read32Bit();
- super.imageFile.skipBytes(4);
- this.bfOffBits = super.imageFile.read32Bit();
- ((ImageLoader)this).print("bfType: " + this.bfType);
- ((ImageLoader)this).print("bfSize: " + this.bfSize);
- ((ImageLoader)this).print("bfOffBits: " + this.bfOffBits);
- this.biSize = super.imageFile.read32Bit();
- this.biWidth = super.imageFile.read32Bit();
- this.biHeight = super.imageFile.read32Bit();
- this.biPlanes = super.imageFile.read16Bit();
- this.biBitCount = super.imageFile.read16Bit();
- if (this.biBitCount < 8) {
- }
-
- if (this.biBitCount < 24) {
- this.colNum = 256;
- }
-
- this.biCompression = super.imageFile.read32Bit();
- this.biSizeImage = super.imageFile.read32Bit();
- super.imageFile.skipBytes(8);
- this.biClrUsed = super.imageFile.read32Bit();
- this.biClrImportant = super.imageFile.read32Bit();
- ((ImageLoader)this).print("biSize: " + this.biSize);
- ((ImageLoader)this).print("biWidth: " + this.biWidth);
- ((ImageLoader)this).print("biHeight: " + this.biHeight);
- ((ImageLoader)this).print("biPlanes: " + this.biPlanes);
- ((ImageLoader)this).print("biBitCount: " + this.biBitCount);
- ((ImageLoader)this).print("biCompression: " + this.biCompression);
- ((ImageLoader)this).print("biSizeImage: " + this.biSizeImage);
- ((ImageLoader)this).print("biClrUsed: " + this.biClrUsed);
- ((ImageLoader)this).print("biClrImportant: " + this.biClrImportant);
- ((ImageLoader)this).initFrameBuffer((int)this.biWidth, (int)this.biHeight);
- }
-
- private void decodeTC() throws IOException {
- ((ImageLoader)this).print("load True Color BMP image");
- int var1 = (int)(this.biWidth * 3L);
- int var2 = var1 >> 2;
- this.padding = var1 - (var2 << 2);
- if (this.padding > 0) {
- this.padding = (var2 + 1 << 2) - var1;
- }
-
- for(; this.pixelCt < this.pixels; ++this.pixelCt) {
- this.red = this.cache[this.cachePtr + 2];
- this.green = this.cache[this.cachePtr + 1];
- this.blue = this.cache[this.cachePtr];
- this.cachePtr += 3;
- super.frameBuffer[this.framePtr] = (this.alpha << 24) + (this.red << 16) + (this.green << 8) + this.blue;
- this.framePtr += this.stepFrameCol;
- ++this.col;
- if (this.col == super.xRes) {
- this.cachePtr += this.padding;
- this.framePtr += this.stepFrameRow;
- this.col = 0;
- }
- }
-
- }
- }
-