1 /* 2 * @(#)Bitmap.java - provides a Bitmap buffer from painted subpic 3 * 4 * Copyright (c) 2004-2005 by dvb.matt, All Rights Reserved. 5 * 6 * This file is part of ProjectX, a free Java based demux utility. 7 * By the authors, ProjectX is intended for educational purposes only, 8 * as a non-commercial test project. 9 * 10 * 11 * This program is free software; you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License as published by 13 * the Free Software Foundation; either version 2 of the License, or 14 * (at your option) any later version. 15 * 16 * This program is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU General Public License for more details. 20 * 21 * You should have received a copy of the GNU General Public License 22 * along with this program; if not, write to the Free Software 23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 24 * 25 */ 26 27 package net.sourceforge.dvb.projectx.subtitle; 28 29 //DM24042004 081.7 int02 introduced 30 31 import java.util.ArrayList; 32 33 public class Bitmap extends Object { 34 35 private int width = 0; 36 private int height = 0; 37 private int depth = 0; 38 private int pixel[] = null; 39 private int page_id = -1; 40 private int region_id = -1; 41 private int object_id = -1; 42 private int x = 0; 43 private int y = 0; 44 private long in_time = -1; 45 private int play_time = -1; 46 private ArrayList color_indices = new ArrayList(); 47 private ArrayList color_table = new ArrayList(); 48 Bitmap()49 public Bitmap() 50 {} 51 Bitmap(int newx, int newy, int w, int h, int[] p, int d, int page, int region, int object, long pts, int time)52 public Bitmap(int newx, int newy, int w, int h, int[] p, int d, int page, int region, int object, long pts, int time) 53 { 54 x = newx; 55 //y = newy; 56 y = newy & ~1; //DM26052004 081.7 int03 changed 57 width = w; 58 height = h; 59 pixel = p; 60 depth = d; 61 page_id = 0xFF & page; 62 region_id = 0xFF & region; 63 object_id = 0xFFFF & object; 64 in_time = pts; 65 play_time = time; 66 } 67 getX()68 public int getX() 69 { 70 return x; 71 } 72 getY()73 public int getY() 74 { 75 return y; 76 } 77 getMaxX()78 public int getMaxX() 79 { 80 return (x + width); 81 } 82 getMaxY()83 public int getMaxY() 84 { 85 return (y + height); 86 } 87 getWidth()88 public int getWidth() 89 { 90 return width; 91 } 92 getHeight()93 public int getHeight() 94 { 95 return height; 96 } 97 setWidth(int val)98 public void setWidth(int val) 99 { 100 width = val; 101 } 102 setHeight(int val)103 public void setHeight(int val) 104 { 105 height = val; 106 } 107 setPixel(int[] p)108 public void setPixel(int[] p) 109 { 110 pixel = p; 111 } 112 getPixel()113 public int[] getPixel() 114 { 115 return pixel; 116 } 117 getDepth()118 public int getDepth() 119 { 120 return depth; 121 } 122 getPageId()123 public int getPageId() 124 { 125 return page_id; 126 } 127 getRegionId()128 public int getRegionId() 129 { 130 return region_id; 131 } 132 getObjectId()133 public int getObjectId() 134 { 135 return object_id; 136 } 137 getId()138 public int getId() 139 { 140 //return (page_id<<24 | region_id<<16 | object_id); 141 return page_id; 142 } 143 setTime(long time_1, int time_2)144 public void setTime(long time_1, int time_2) 145 { 146 in_time = time_1; 147 play_time = time_2; 148 } 149 getInTime()150 public long getInTime() 151 { 152 return in_time; 153 } 154 getPlayTime()155 public int getPlayTime() 156 { 157 return play_time; 158 } 159 createColorTable()160 public void createColorTable() 161 { 162 for (int a=0; a < pixel.length; a++) 163 { 164 String pixel_str = "" + pixel[a]; 165 166 if (color_table.contains(pixel_str)) 167 continue; 168 169 else 170 color_table.add(pixel_str); 171 } 172 } 173 clearColorTable()174 public void clearColorTable() 175 { 176 color_table.clear(); 177 } 178 getColorTable()179 public Object[] getColorTable() 180 { 181 return color_table.toArray(); 182 } 183 getColorTableArray()184 public ArrayList getColorTableArray() 185 { 186 return color_table; 187 } 188 189 // returns 0 .. 3, indices > 3 mapped to 3 getColorIndex(int color_index)190 public int getColorIndex(int color_index) 191 { 192 String color_index_str = "" + color_index; 193 int index = color_indices.indexOf(color_index_str); 194 195 if (index != -1) 196 return index; 197 198 else if (color_indices.size() < 4) 199 color_indices.add(color_index_str); 200 201 return (color_indices.size() - 1); 202 } 203 clearColorIndices()204 public void clearColorIndices() 205 { 206 color_indices.clear(); 207 } 208 getColorIndices()209 public Object[] getColorIndices() 210 { 211 return color_indices.toArray(); 212 } 213 } 214