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