VobSubImage.h

00001 /* 
00002  *      Copyright (C) 2003-2005 Gabest
00003  *      http://www.gabest.org
00004  *
00005  *  This Program is free software; you can redistribute it and/or modify
00006  *  it under the terms of the GNU General Public License as published by
00007  *  the Free Software Foundation; either version 2, or (at your option)
00008  *  any later version.
00009  *   
00010  *  This Program is distributed in the hope that it will be useful,
00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00013  *  GNU General Public License for more details.
00014  *   
00015  *  You should have received a copy of the GNU General Public License
00016  *  along with GNU Make; see the file COPYING.  If not, write to
00017  *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 
00018  *  http://www.gnu.org/copyleft/gpl.html
00019  *
00020  */
00021 
00022 #pragma once
00023 
00024 #include <afx.h>
00025 #include <afxtempl.h>
00026 #include <atlcoll.h>
00027 
00028 typedef CArray<CPoint> CPointArray;
00029 typedef CArray<int> CDirArray;
00030 
00031 typedef struct 
00032 {
00033         CPointArray pa;
00034         CDirArray da;
00035         void RemoveAll() {pa.RemoveAll(); da.RemoveAll();}
00036         void Add(CPoint p, int d) {pa.Add(p); da.Add(d);}
00037 } COutline;
00038 
00039 typedef CAutoPtrList<COutline> COutlineList;
00040 
00041 class CVobSubImage
00042 {
00043         friend class CVobSubFile;
00044 
00045 private:
00046         CSize org;
00047         RGBQUAD* lpTemp1;
00048         RGBQUAD* lpTemp2;
00049 
00050         WORD nOffset[2], nPlane;
00051         bool fCustomPal;
00052         char fAligned; // we are also using this for calculations, that's why it is char instead of bool...
00053         int tridx;
00054         RGBQUAD* orgpal /*[16]*/,* cuspal /*[4]*/;
00055 
00056         bool Alloc(int w, int h);
00057         void Free();
00058 
00059         BYTE GetNibble(BYTE* lpData);
00060         void DrawPixels(CPoint p, int length, int colorid);
00061         void TrimSubImage();
00062 
00063 public:
00064         int iLang, iIdx;
00065         bool fForced;
00066         __int64 start, delay;
00067         CRect rect;
00068         typedef struct {BYTE pal:4, tr:4;} SubPal;
00069         SubPal pal[4];
00070         RGBQUAD* lpPixels;
00071 
00072         CVobSubImage();
00073         virtual ~CVobSubImage();
00074 
00075         void Invalidate() {iLang = iIdx = -1;}
00076 
00077         void GetPacketInfo(BYTE* lpData, int packetsize, int datasize);
00078         bool Decode(BYTE* lpData, int packetsize, int datasize,
00079                                 bool fCustomPal, 
00080                                 int tridx, 
00081                                 RGBQUAD* orgpal /*[16]*/, RGBQUAD* cuspal /*[4]*/, 
00082                                 bool fTrim);
00083 
00085 
00086 private:
00087         COutlineList* GetOutlineList(CPoint& topleft);
00088         int GrabSegment(int start, COutline& o, COutline& ret);
00089         void SplitOutline(COutline& o, COutline& o1, COutline& o2);
00090         void AddSegment(COutline& o, CByteArray& pathTypes, CPointArray& pathPoints);
00091 
00092 public:
00093         bool Polygonize(CByteArray& pathTypes, CPointArray& pathPoints, bool fSmooth, int scale);
00094         bool Polygonize(CStringW& assstr, bool fSmooth = true, int scale = 3);
00095 
00096     void Scale2x();
00097 };

Generated on Tue Dec 13 14:47:57 2005 for guliverkli by  doxygen 1.4.5