App

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List
- File Members

BitmapInfo.java
Go to the documentation of this file.
1 package mhr.appcore.bitmap;
2
3 import mhr.appcore.utils.Rect;
4
8 public class BitmapInfo {
9 public int width = 0;
10 public int height = 0;
11 public boolean premultiplied = false;
12 public ChannelCount channelCount = ChannelCount.INVALID_COUNT;
13 public Depth depth = Depth.INVALID_DEPTH;
14 public ColorMode colorMode = ColorMode.INVALID_COLOR_MODE;
15
19 public BitmapInfo() {
20 }
21
31 public BitmapInfo(int width, int height, ChannelCount channelCount, Depth depth, ColorMode colorMode, boolean premultiplied) {
32 this.width = width;
33 this.height = height;
34 this.premultiplied = premultiplied;
35 this.channelCount = channelCount;
36 this.depth = depth;
37 this.colorMode = colorMode;
38 }
39
44 public BitmapInfo(BitmapInfo other) {
45 this.width = other.width;
46 this.height = other.height;
47 this.premultiplied = other.premultiplied;
48 this.channelCount = other.channelCount;
49 this.depth = other.depth;
50 this.colorMode = other.colorMode;
51 }
52
57 public boolean isValid() {
58 if (width > 0 && height > 0 && channelCount != ChannelCount.INVALID_COUNT && depth != Depth.INVALID_DEPTH && colorMode != ColorMode.INVALID_COLOR_MODE) {
59 return true;
60 } else {
61 return false;
62 }
63 }
64
69 public Rect getRect() {
70 return new Rect(width, height);
71 }
72
79 public NativeType getNativeType() {
80 if (width > 0 && height > 0) {
81 if (channelCount == ChannelCount.SINGLE_CHANNEL && colorMode == ColorMode.MONO) {
82 if (depth == Depth.DEPTH_8_BIT) {
83 return NativeType.MONO_8_BIT;
84 }
85 } else if (channelCount == ChannelCount.FOUR_CHANNEL && colorMode != ColorMode.INVALID_COLOR_MODE && colorMode != ColorMode.MONO) {
86 if (depth == Depth.DEPTH_8_BIT) {
87 return NativeType.RGBA_8_BIT;
88 }
89 }
90 }
91 return NativeType.INVALID_TYPE;
92 }
93 }