Fixed a bug

This commit is contained in:
Andrea Cavalli 2018-06-14 12:20:01 +02:00
parent 638200f6bb
commit a9e4bccecb
16 changed files with 119 additions and 33 deletions

View File

@ -3,9 +3,14 @@ package ar.com.hjg.pngj;
public class Deinterlacer { public class Deinterlacer {
final ImageInfo imi; final ImageInfo imi;
private int pass; // 1-7 private int pass; // 1-7
private int rows, cols; private int rows;
int dY, dX, oY, oX; // current step and offset (in pixels) private int cols;
int oXsamples, dXsamples; // step in samples int dY; // current step and offset (in pixels)
int dX;
int oY;
int oX;
int oXsamples; // step in samples
int dXsamples;
// current row in the virtual subsampled image; this increments (by 1) from 0 to rows/dy 7 times // current row in the virtual subsampled image; this increments (by 1) from 0 to rows/dy 7 times
private int currRowSubimg; private int currRowSubimg;

View File

@ -12,7 +12,9 @@ public abstract class ImageLineSetDefault<T extends IImageLine> implements IImag
protected final ImageInfo imgInfo; protected final ImageInfo imgInfo;
private final boolean singleCursor; private final boolean singleCursor;
private final int nlines, offset, step; private final int nlines;
private final int offset;
private final int step;
protected List<T> imageLines; // null if single cursor protected List<T> imageLines; // null if single cursor
protected T imageLine; // null unless single cursor protected T imageLine; // null unless single cursor
protected int currentRow = -1; // only relevant (and not much) for cursor protected int currentRow = -1; // only relevant (and not much) for cursor

View File

@ -7,12 +7,16 @@ class RowInfo {
public final ImageInfo imgInfo; public final ImageInfo imgInfo;
public final Deinterlacer deinterlacer; public final Deinterlacer deinterlacer;
public final boolean imode; // Interlaced public final boolean imode; // Interlaced
int dY, dX, oY, oX; // current step and offset (in pixels) int dY; // current step and offset (in pixels)
int dX;
int oY;
int oX;
int rowNseq; // row number (from 0) in sequential read order int rowNseq; // row number (from 0) in sequential read order
int rowNreal; // row number in the real image int rowNreal; // row number in the real image
int rowNsubImg; // current row in the virtual subsampled image; this increments (by 1) from 0 to int rowNsubImg; // current row in the virtual subsampled image; this increments (by 1) from 0 to
// rows/dy 7 times // rows/dy 7 times
int rowsSubImg, colsSubImg; // size of current subimage , in pixels int rowsSubImg; // size of current subimage , in pixels
int colsSubImg;
int bytesRow; int bytesRow;
int pass; // 1-7 int pass; // 1-7
byte[] buf; // non-deep copy byte[] buf; // non-deep copy

View File

@ -26,7 +26,15 @@ public abstract class PngChunk {
/** /**
* Autocomputed at creation time * Autocomputed at creation time
*/ */
public final boolean crit, pub, safe; public final boolean crit;
/**
* Autocomputed at creation time
*/
public final boolean pub;
/**
* Autocomputed at creation time
*/
public final boolean safe;
protected final ImageInfo imgInfo; protected final ImageInfo imgInfo;

View File

@ -15,7 +15,9 @@ public class PngChunkBKGD extends PngChunkSingle {
public final static String ID = ChunkHelper.bKGD; public final static String ID = ChunkHelper.bKGD;
// only one of these is meaningful // only one of these is meaningful
private int gray; private int gray;
private int red, green, blue; private int red;
private int green;
private int blue;
private int paletteIndex; private int paletteIndex;
public PngChunkBKGD(ImageInfo info) { public PngChunkBKGD(ImageInfo info) {

View File

@ -13,10 +13,18 @@ public class PngChunkCHRM extends PngChunkSingle {
public final static String ID = ChunkHelper.cHRM; public final static String ID = ChunkHelper.cHRM;
// http://www.w3.org/TR/PNG/#11cHRM // http://www.w3.org/TR/PNG/#11cHRM
private double whitex, whitey; private double whitex;
private double redx, redy;
private double greenx, greeny; private double whitey;
private double bluex, bluey; private double redx;
private double redy;
private double greenx;
private double greeny;
private double bluex;
private double bluey;
public PngChunkCHRM(ImageInfo info) { public PngChunkCHRM(ImageInfo info) {
super(ID, info); super(ID, info);

View File

@ -19,9 +19,19 @@ public class PngChunkFCTL extends PngChunkMultiple {
public final static byte APNG_BLEND_OP_OVER = 1; public final static byte APNG_BLEND_OP_OVER = 1;
private int seqNum; private int seqNum;
private int width, height, xOff, yOff; private int width;
private int delayNum, delayDen;
private byte disposeOp, blendOp; private int height;
private int xOff;
private int yOff;
private int delayNum;
private int delayDen;
private byte disposeOp;
private byte blendOp;
public PngChunkFCTL(ImageInfo info) { public PngChunkFCTL(ImageInfo info) {
super(ID, info); super(ID, info);

View File

@ -16,8 +16,14 @@ public class PngChunkSBIT extends PngChunkSingle {
// http://www.w3.org/TR/PNG/#11sBIT // http://www.w3.org/TR/PNG/#11sBIT
// significant bits // significant bits
private int graysb, alphasb; private int graysb;
private int redsb, greensb, bluesb;
private int alphasb;
private int redsb;
private int greensb;
private int bluesb;
public PngChunkSBIT(ImageInfo info) { public PngChunkSBIT(ImageInfo info) {
super(ID, info); super(ID, info);

View File

@ -15,7 +15,17 @@ public class PngChunkTIME extends PngChunkSingle {
public final static String ID = ChunkHelper.tIME; public final static String ID = ChunkHelper.tIME;
// http://www.w3.org/TR/PNG/#11tIME // http://www.w3.org/TR/PNG/#11tIME
private int year, mon, day, hour, min, sec; private int year;
private int mon;
private int day;
private int hour;
private int min;
private int sec;
public PngChunkTIME(ImageInfo info) { public PngChunkTIME(ImageInfo info) {
super(ID, info); super(ID, info);

View File

@ -18,7 +18,11 @@ public class PngChunkTRNS extends PngChunkSingle {
// only one of these is meaningful, depending on the image type // only one of these is meaningful, depending on the image type
private int gray; private int gray;
private int red, green, blue; private int red;
private int green;
private int blue;
private int[] paletteAlpha = new int[] {}; private int[] paletteAlpha = new int[] {};
public PngChunkTRNS(ImageInfo info) { public PngChunkTRNS(ImageInfo info) {

View File

@ -29,7 +29,9 @@ public class PixelsWriterMultiple extends PixelsWriter {
// smaller than rowsPerBand // smaller than rowsPerBand
protected int rowInBand = -1; protected int rowInBand = -1;
protected int bandNum = -1; protected int bandNum = -1;
protected int firstRowInThisBand, lastRowInThisBand; protected int firstRowInThisBand;
protected int lastRowInThisBand;
private boolean tryAdaptive = true; private boolean tryAdaptive = true;
protected static final int HINT_MEMORY_DEFAULT_KB = 100; protected static final int HINT_MEMORY_DEFAULT_KB = 100;

View File

@ -25,6 +25,7 @@ import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
import org.warp.picalculator.ClassUtils;
import org.warp.picalculator.Main; import org.warp.picalculator.Main;
import com.jogamp.common.util.IOUtil; import com.jogamp.common.util.IOUtil;
@ -50,7 +51,7 @@ public class StorageUtils {
@Deprecated() @Deprecated()
public static File getResource(String string) throws IOException, URISyntaxException { public static File getResource(String string) throws IOException, URISyntaxException {
final URL res = Main.instance.getClass().getResource(string); final URL res = ClassUtils.classLoader.getResource(string);
final boolean isResource = res != null; final boolean isResource = res != null;
if (isResource) { if (isResource) {
try { try {
@ -93,7 +94,7 @@ public class StorageUtils {
} }
public static InputStream getResourceStream(String string) throws IOException, URISyntaxException { public static InputStream getResourceStream(String string) throws IOException, URISyntaxException {
final URL res = Main.instance.getClass().getResource(string); final URL res = ClassUtils.classLoader.getResource(string);
final boolean isResource = res != null; final boolean isResource = res != null;
if (isResource) { if (isResource) {
try { try {

View File

@ -11,6 +11,7 @@ import java.util.logging.Logger;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
import org.warp.picalculator.ClassUtils;
import org.warp.picalculator.Main; import org.warp.picalculator.Main;
import org.warp.picalculator.Utils; import org.warp.picalculator.Utils;
import org.warp.picalculator.deps.DSystem; import org.warp.picalculator.deps.DSystem;
@ -75,7 +76,7 @@ public class RAWFont {
} }
private void loadFont(String string) throws IOException { private void loadFont(String string) throws IOException {
final URL res = Main.instance.getClass().getResource(string); final URL res = ClassUtils.classLoader.getClass().getResource(string);
final int[] file = Utils.realBytes(Utils.convertStreamToByteArray(res.openStream(), res.getFile().length())); final int[] file = Utils.realBytes(Utils.convertStreamToByteArray(res.openStream(), res.getFile().length()));
final int filelength = file.length; final int filelength = file.length;
if (filelength >= 16) { if (filelength >= 16) {

View File

@ -1,7 +1,8 @@
package org.warp.picalculator.extra.mario; package org.warp.picalculator.extra.mario;
public class MarioBlock { public class MarioBlock {
private final int x, y; private final int x;
private final int y;
private final byte id; private final byte id;
public MarioBlock(int x, int y, byte b) { public MarioBlock(int x, int y, byte b) {

View File

@ -18,11 +18,18 @@ public class GraphicUtils {
} }
@SuppressWarnings("unused") @SuppressWarnings("unused")
private static final float RAD, DEG; private static final float RAD;
private static final int SIN_BITS, SIN_MASK, SIN_COUNT; @SuppressWarnings("unused")
private static final float radFull, radToIndex; private static final float DEG;
private static final float degFull, degToIndex; private static final int SIN_BITS;
private static final float[] sin, cos; private static final int SIN_MASK;
private static final int SIN_COUNT;
private static final float radFull;
private static final float radToIndex;
private static final float degFull;
private static final float degToIndex;
private static final float[] sin;
private static final float[] cos;
static { static {
RAD = (float) Math.PI / 180.0f; RAD = (float) Math.PI / 180.0f;

View File

@ -28,10 +28,25 @@ public class GPURenderer implements Renderer {
public static GL2ES1 gl; public static GL2ES1 gl;
private static final int ELEMENTS_MAX_COUNT_PER_BUFFER = StaticVars.enableVBO ? 128 : 1; private static final int ELEMENTS_MAX_COUNT_PER_BUFFER = StaticVars.enableVBO ? 128 : 1;
private static final int ELEMENT_VERTICES_COUNT = 6, vertSize = 3, texSize = 2, colSize = 4, vertBuffer = 0, private static final int ELEMENT_VERTICES_COUNT = 6;
texBuffer = 1, colBuffer = 2, vertMax = vertSize * ELEMENT_VERTICES_COUNT * ELEMENTS_MAX_COUNT_PER_BUFFER,
texMax = texSize * ELEMENT_VERTICES_COUNT * ELEMENTS_MAX_COUNT_PER_BUFFER, private static final int vertSize = 3;
colMax = colSize * ELEMENT_VERTICES_COUNT * ELEMENTS_MAX_COUNT_PER_BUFFER;
private static final int texSize = 2;
private static final int colSize = 4;
private static final int vertBuffer = 0;
private static final int texBuffer = 1;
private static final int colBuffer = 2;
private static final int vertMax = vertSize * ELEMENT_VERTICES_COUNT * ELEMENTS_MAX_COUNT_PER_BUFFER;
private static final int texMax = texSize * ELEMENT_VERTICES_COUNT * ELEMENTS_MAX_COUNT_PER_BUFFER;
private static final int colMax = colSize * ELEMENT_VERTICES_COUNT * ELEMENTS_MAX_COUNT_PER_BUFFER;
private int[] handlers; private int[] handlers;
private final DeallocationHelper deallocationHelper = new DeallocationHelper(); private final DeallocationHelper deallocationHelper = new DeallocationHelper();