diff options
author | deva <deva> | 2005-11-16 11:53:21 +0000 |
---|---|---|
committer | deva <deva> | 2005-11-16 11:53:21 +0000 |
commit | 32183390270df57a49d932b9fe51012146ce154f (patch) | |
tree | 2b5095cb11412e29e612a26b3feb7ed5dc8e9cb5 /src/yuv_draw.cc | |
parent | 2ec93410616c86a3fd0e4464d34c4b5da77b13d5 (diff) |
*** empty log message ***
Diffstat (limited to 'src/yuv_draw.cc')
-rw-r--r-- | src/yuv_draw.cc | 62 |
1 files changed, 34 insertions, 28 deletions
diff --git a/src/yuv_draw.cc b/src/yuv_draw.cc index bb8b23f..06aff5c 100644 --- a/src/yuv_draw.cc +++ b/src/yuv_draw.cc @@ -36,6 +36,26 @@ #define TEXT_MARGIN 10 +#include "mainwindow.h" +static QImage *loadIcon( char *name, int height ) +{ + QImage scaled; + QImage *img; + + img = new QImage(); + img->load( name ); + + int h = height; + int w = (int)((float)img->width() / (float)(img->height() / (float)h)); + + scaled = img->smoothScale(w, h); + delete img; + img = new QImage(scaled); + + return img; +} + + YUVDraw::YUVDraw() { overlay = NULL; @@ -56,6 +76,8 @@ YUVDraw::YUVDraw() } } + img_muted = loadIcon(PIXMAP_MUTE, ICON_HEIGHT); + img_unmuted = loadIcon(PIXMAP_UNMUTE, ICON_HEIGHT); } YUVDraw::~YUVDraw() @@ -93,12 +115,12 @@ void YUVDraw::setTopText(char* text) painter.begin(top_pixmap); painter.setFont( QFont( "Arial", 12, QFont::Bold ) ); painter.setPen( Qt::black ); - painter.drawText(0, 15, text); + painter.drawText(64, 15, text); painter.end(); QImage image = top_pixmap->convertToImage(); - for(int x = 0; x < 720 - TEXT_MARGIN; x++) { + for(int x = 64; x < 720 - TEXT_MARGIN; x++) { for(int y = 0; y < 20; y++) { top_grey[x][y] = qGray(image.pixel(x, y)); } @@ -143,39 +165,23 @@ void YUVDraw::draw() } } -static QImage *loadIcon( char *name, int height ) -{ - QImage scaled; - QImage *img; - - img = new QImage(); - img->load( name ); - - int h = height; - int w = (int)((float)img->width() / (float)(img->height() / (float)h)); - - scaled = img->smoothScale(w, h); - delete img; - img = new QImage(scaled); - - return img; -} -#include "mainwindow.h" void YUVDraw::mute(bool muted) { int xoffset = 0; int yoffset = 0; - int width = 48; - int height = 48; - QImage *img = loadIcon(PIXMAP_UNMUTE, height); + QImage *img; + if(muted) img = img_muted; + else img = img_unmuted; // Swicth the bool and draw an mute/unmute symbol - for(int x = 0; x < width; x++) { - for(int y = 0; y < height; y++) { - unsigned char color = qGray(img->pixel(x, y)); - if(!qAlpha(img->pixel(x, y))) color = 0; - addPixel(x + xoffset, y + yoffset, color); + float alpha, color; + + for(int x = 0; x < ICON_WIDTH; x++) { + for(int y = 0; y < ICON_HEIGHT; y++) { + alpha = ((float)qAlpha(img->pixel(x, y)) / 255.0); + color = (float)qGray(img->pixel(x, y)) * alpha; + addPixel(x + xoffset, y + yoffset, (unsigned char)color); } } } |