aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkSTER.java
blob: 4dc5edec5d8853c62205b769dc98bcfa0ebfad2d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package jogamp.opengl.util.pngj.chunks;

import jogamp.opengl.util.pngj.ImageInfo;
import jogamp.opengl.util.pngj.PngjException;

/**
 * sTER chunk.
 * <p>
 * see http://www.libpng.org/pub/png/spec/register/pngext-1.3.0-pdg.html#C.sTER
 */
public class PngChunkSTER extends PngChunkSingle {
	public final static String ID = "sTER";

	// http://www.libpng.org/pub/png/spec/register/pngext-1.3.0-pdg.html#C.sTER
	private byte mode; // 0: cross-fuse layout 1: diverging-fuse layout

	public PngChunkSTER(ImageInfo info) {
		super(ID, info);
	}

	@Override
	public ChunkOrderingConstraint getOrderingConstraint() {
		return ChunkOrderingConstraint.BEFORE_IDAT;
	}

	@Override
	public ChunkRaw createRawChunk() {
		ChunkRaw c = createEmptyChunk(1, true);
		c.data[0] = (byte) mode;
		return c;
	}

	@Override
	public void parseFromRaw(ChunkRaw chunk) {
		if (chunk.len != 1)
			throw new PngjException("bad chunk length " + chunk);
		mode = chunk.data[0];
	}

	@Override
	public void cloneDataFromRead(PngChunk other) {
		PngChunkSTER otherx = (PngChunkSTER) other;
		this.mode = otherx.mode;
	}

	/**
	 * 0: cross-fuse layout 1: diverging-fuse layout
	 */
	public byte getMode() {
		return mode;
	}

	/**
	 * 0: cross-fuse layout 1: diverging-fuse layout
	 */
	public void setMode(byte mode) {
		this.mode = mode;
	}

}