22163e33a7558df76e1f22ed93af575325c4b439
[imagesqueeze.git] / src / main / java / eu / svjatoslav / imagesqueeze / codec / ImageMetaData.java
1 /*
2  * Imagesqueeze - Image codec. Copyright ©2012-2019, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of version 3 of the GNU Lesser General Public License
6  * or later as published by the Free Software Foundation.
7  */
8
9 package eu.svjatoslav.imagesqueeze.codec;
10
11 /**
12  * Class to hold image metadata.
13  * Like image dimensions, header version, compression quality, etc..
14  */
15
16 import eu.svjatoslav.commons.data.BitInputStream;
17 import eu.svjatoslav.commons.data.BitOutputStream;
18
19 import java.io.IOException;
20
21 public class ImageMetaData {
22
23     int version;
24     int width;
25     int height;
26
27     public void load(final BitInputStream inputStream) throws IOException {
28         version = inputStream.readBits(16);
29         width = ImageDecoder.readIntegerCompressed8(inputStream);
30         height = ImageDecoder.readIntegerCompressed8(inputStream);
31     }
32
33     public void save(final BitOutputStream outputStream) throws IOException {
34         outputStream.storeBits(version, 16);
35         ImageEncoder.storeIntegerCompressed8(outputStream, width);
36         ImageEncoder.storeIntegerCompressed8(outputStream, height);
37     }
38
39 }