Change default sub-pixel positioning option to the same as VSFilter 2.39 default.
[xy_vsfilter.git] / include / virtualdub / VBitmap.h
blobc18e553dc7e5621b703bf530d7a46c158f1d5b65
1 #ifndef f_VIRTUALDUB_VBITMAP_H
2 #define f_VIRTUALDUB_VBITMAP_H
4 #include <windows.h>
6 typedef unsigned long Pixel;
7 typedef unsigned long Pixel32;
8 typedef unsigned char Pixel8;
9 typedef long PixCoord;
10 typedef long PixDim;
11 typedef long PixOffset;
13 #ifdef VDEXT_VIDEO_FILTER
14 #define NOVTABLE __declspec(novtable)
15 #else
16 #define NOVTABLE
17 #endif
19 class NOVTABLE VBitmap {
20 public:
21 Pixel * data;
22 Pixel * palette;
23 int depth;
24 PixCoord w, h;
25 PixOffset pitch;
26 PixOffset modulo;
27 PixOffset size;
28 PixOffset offset;
30 Pixel *Address(PixCoord x, PixCoord y) const {
31 return Addressi(x, h-y-1);
34 Pixel *Addressi(PixCoord x, PixCoord y) const {
35 return (Pixel *)((char *)data + y*pitch + x*(depth>>3));
38 Pixel *Address32(PixCoord x, PixCoord y) const {
39 return Address32i(x, h-y-1);
42 Pixel *Address32i(PixCoord x, PixCoord y) const {
43 return (Pixel *)((char *)data + y*pitch + x*sizeof(Pixel));
46 PixOffset PitchAlign4() {
47 return ((w * depth + 31)/32)*4;
50 PixOffset PitchAlign8() {
51 return ((w * depth + 63)/64)*8;
54 PixOffset Modulo() {
55 return pitch - (w*depth+7)/8;
58 PixOffset Size() {
59 return pitch*h;
62 //////
64 VBitmap() throw() {
65 #ifdef VDEXT_VIDEO_FILTER
66 init();
67 #endif
69 VBitmap(void *data, PixDim w, PixDim h, int depth) throw();
70 VBitmap(void *data, BITMAPINFOHEADER *) throw();
72 #ifdef VDEXT_VIDEO_FILTER
73 void init() throw() { *(void **)this = g_vtbls.pvtblVBitmap; }
74 #endif
76 virtual VBitmap& init(void *data, PixDim w, PixDim h, int depth) throw();
77 virtual VBitmap& init(void *data, BITMAPINFOHEADER *) throw();
79 virtual void MakeBitmapHeader(BITMAPINFOHEADER *bih) const throw();
81 virtual void AlignTo4() throw();
82 virtual void AlignTo8() throw();
84 virtual void BitBlt(PixCoord x2, PixCoord y2, const VBitmap *src, PixCoord x1, PixCoord y1, PixDim dx, PixDim dy) const throw();
85 virtual void BitBltDither(PixCoord x2, PixCoord y2, const VBitmap *src, PixDim x1, PixDim y1, PixDim dx, PixDim dy, bool to565) const throw();
86 virtual void BitBlt565(PixCoord x2, PixCoord y2, const VBitmap *src, PixDim x1, PixDim y1, PixDim dx, PixDim dy) const throw();
88 virtual bool BitBltXlat1(PixCoord x2, PixCoord y2, const VBitmap *src, PixCoord x1, PixCoord y1, PixDim dx, PixDim dy, const Pixel8 *tbl) const throw();
89 virtual bool BitBltXlat3(PixCoord x2, PixCoord y2, const VBitmap *src, PixCoord x1, PixCoord y1, PixDim dx, PixDim dy, const Pixel32 *tbl) const throw();
91 virtual bool StretchBltNearestFast(PixCoord x1, PixCoord y1, PixDim dx, PixDim dy, const VBitmap *src, double x2, double y2, double dx1, double dy1) const throw();
93 virtual bool StretchBltBilinearFast(PixCoord x1, PixCoord y1, PixDim dx, PixDim dy, const VBitmap *src, double x2, double y2, double dx1, double dy1) const throw();
95 virtual bool RectFill(PixCoord x1, PixCoord y1, PixDim dx, PixDim dy, Pixel32 c) const throw();
97 enum {
98 HISTO_LUMA,
99 HISTO_GRAY,
100 HISTO_RED,
101 HISTO_GREEN,
102 HISTO_BLUE,
105 virtual bool Histogram(PixCoord x, PixCoord y, PixCoord dx, PixCoord dy, long *pHisto, int iHistoType) const throw();
107 private:
108 bool dualrectclip(PixCoord& x2, PixCoord& y2, const VBitmap *src, PixCoord& x1, PixCoord& y1, PixDim& dx, PixDim& dy) const throw();
111 #undef NOVTABLE
113 #endif