7 # include <vlc_codecs.h>
12 #include "AtmoZoneDefinition.h"
14 CAtmoZoneDefinition::CAtmoZoneDefinition(void)
18 CAtmoZoneDefinition::~CAtmoZoneDefinition(void)
22 void CAtmoZoneDefinition::Fill(unsigned char value)
24 for(int i=0; i < IMAGE_SIZE; i++)
25 m_BasicWeight[i] = value;
29 void CAtmoZoneDefinition::FillGradientFromLeft()
32 unsigned char col_norm;
33 for(int row=0; row < CAP_HEIGHT; row++) {
34 for(int col=0; col < CAP_WIDTH; col++) {
35 // should be a value between 0 .. 255?
36 col_norm = (255 * (CAP_WIDTH-col-1)) / (CAP_WIDTH-1);
37 m_BasicWeight[index++] = col_norm;
42 // max weight to right
43 void CAtmoZoneDefinition::FillGradientFromRight()
46 unsigned char col_norm;
47 for(int row=0; row < CAP_HEIGHT; row++) {
48 for(int col=0; col < CAP_WIDTH; col++) {
49 col_norm = (255 * col) / (CAP_WIDTH-1); // should be a value between 0 .. 255?
50 m_BasicWeight[index++] = col_norm;
55 // max weight from top
56 void CAtmoZoneDefinition::FillGradientFromTop()
59 unsigned char row_norm;
60 for(int row=0; row < CAP_HEIGHT; row++) {
61 row_norm = (255 * (CAP_HEIGHT-row-1)) / (CAP_HEIGHT-1); // should be a value between 0 .. 255?
62 for(int col=0; col < CAP_WIDTH; col++) {
63 m_BasicWeight[index++] = row_norm;
68 // max weight from bottom
69 void CAtmoZoneDefinition::FillGradientFromBottom()
72 unsigned char row_norm;
73 for(int row=0; row < CAP_HEIGHT; row++) {
74 row_norm = (255 * row) / (CAP_HEIGHT-1); // should be a value between 0 .. 255?
75 for(int col=0; col < CAP_WIDTH; col++) {
76 m_BasicWeight[index++] = row_norm;
82 int CAtmoZoneDefinition::LoadGradientFromBitmap(char *pszBitmap)
84 // transform 256 color image (gray scale!)
85 // into m_basicWeight or use the GREEN value of a 24bit image!
86 // channel of a true color bitmap!
88 BITMAPFILEHEADER bmpFileHeader;
91 #define ATMO_LOAD_GRADIENT_OK 0
92 #define ATMO_LOAD_GRADIENT_FAILED_SIZE 1
93 #define ATMO_LOAD_GRADIENT_FAILED_HEADER 2
97 FILE *bmp = fopen(pszBitmap, "rb");
99 return ATMO_LOAD_GRADIENT_FILENOTFOND;
101 if(fread(&bmpFileHeader, sizeof(BITMAPFILEHEADER), 1, bmp) != 1)
104 return ATMO_LOAD_GRADIENT_FAILED_SIZE;
106 #ifdef _ATMO_VLC_PLUGIN_
107 if(bmpFileHeader.bfType != VLC_TWOCC('M','B'))
109 if(bmpFileHeader.bfType != MakeWord('M','B'))
113 return ATMO_LOAD_GRADIENT_FAILED_HEADER;
116 if(fread(&bmpInfo, sizeof(BITMAPINFO), 1, bmp) != 1)
119 return ATMO_LOAD_GRADIENT_FAILED_SIZE;
122 if(bmpInfo.bmiHeader.biCompression != BI_RGB)
125 return ATMO_LOAD_GRADIENT_FAILED_FORMAT;
127 if((bmpInfo.bmiHeader.biBitCount != 8) && (bmpInfo.bmiHeader.biBitCount != 24))
130 return ATMO_LOAD_GRADIENT_FAILED_FORMAT;
133 int width = bmpInfo.bmiHeader.biWidth;
134 int height = bmpInfo.bmiHeader.biHeight;
135 ATMO_BOOL invertDirection = (height > 0);
136 height = abs(height);
137 if((width != CAP_WIDTH) || (height != CAP_HEIGHT))
140 return ATMO_LOAD_GRADIENT_FAILED_SIZE;
143 fseek(bmp, bmpFileHeader.bfOffBits, SEEK_SET);
145 int imageSize = width * height * bmpInfo.bmiHeader.biBitCount/8;
147 unsigned char *pixelBuffer = (unsigned char *)malloc(imageSize);
148 if(fread(pixelBuffer,imageSize,1,bmp) != 1)
151 return ATMO_LOAD_GRADIENT_FAILED_SIZE;
154 if(bmpInfo.bmiHeader.biBitCount == 8)
157 for(int y=0;y < CAP_HEIGHT; y++) {
158 if(invertDirection) {
159 ydest = (CAP_HEIGHT - y - 1);
163 for(int x=0;x < CAP_WIDTH; x++) {
164 // palette should be grey scale - so that index 0 is black and
165 // index 255 means white!
166 // everything else would produce funny results!
167 m_BasicWeight[ydest * CAP_WIDTH + x] =
168 pixelBuffer[y * CAP_WIDTH + x];
173 if(bmpInfo.bmiHeader.biBitCount == 24)
176 for(int y=0;y < CAP_HEIGHT; y++) {
177 if(invertDirection) {
178 ydest = (CAP_HEIGHT - y - 1);
182 for(int x=0;x < CAP_WIDTH; x++) {
183 // use the green value as reference...
184 m_BasicWeight[ydest * CAP_WIDTH + x] =
185 pixelBuffer[y * CAP_WIDTH * 3 + (x*3) + 1 ];
192 return ATMO_LOAD_GRADIENT_OK;
196 void CAtmoZoneDefinition::UpdateWeighting(int *destWeight,
198 int newEdgeWeightning)
201 use the values in m_BasicWeight and newWeightning to
202 update the direct control array for the output thread!
206 for(int row=0; row < CAP_HEIGHT; row++) {
207 for(int col=0; col < CAP_HEIGHT; col++) {
208 if ((WidescreenMode == 1) && ((row <= CAP_HEIGHT/8) || (row >= (7*CAP_HEIGHT)/8)))
210 destWeight[index] = 0;
212 destWeight[index] = (int)(255.0 * (float)pow( ((float)m_BasicWeight[index])/255.0 , newEdgeWeightning));
219 void CAtmoZoneDefinition::setZoneNumber(int num)
224 int CAtmoZoneDefinition::getZoneNumber()