summaryrefslogtreecommitdiff
path: root/src/yuv_draw.cc
diff options
context:
space:
mode:
authordeva <deva>2006-06-09 18:20:51 +0000
committerdeva <deva>2006-06-09 18:20:51 +0000
commit8f9101869f6b460f61033ce434bba0a793d25137 (patch)
treefd07cb44be0b01da339f79164c323793d72ab4a9 /src/yuv_draw.cc
parent6c31ad03de714676516d69ae9114e8bdd67c0d96 (diff)
Moved files to other folder:
lib - Shared files between server and client client - Client files server - Server files
Diffstat (limited to 'src/yuv_draw.cc')
-rw-r--r--src/yuv_draw.cc242
1 files changed, 0 insertions, 242 deletions
diff --git a/src/yuv_draw.cc b/src/yuv_draw.cc
deleted file mode 100644
index 06aff5c..0000000
--- a/src/yuv_draw.cc
+++ /dev/null
@@ -1,242 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/***************************************************************************
- * yuv_draw.cc
- *
- * Thu Sep 22 12:35:28 CEST 2005
- * Copyright 2005 Bent Bisballe Nyeng
- * deva@aasimon.org
- ****************************************************************************/
-
-/*
- * This file is part of MIaV.
- *
- * MIaV is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * MIaV is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with MIaV; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- */
-#include "config.h"
-#ifdef USE_GUI
-#include "yuv_draw.h"
-
-// for miav_app
-#include "miav.h"
-
-//#include "font.h"
-#include <string.h>
-
-#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;
-
- // One line of text!
- top_pixmap = new QPixmap(720 - TEXT_MARGIN, 20);
- bottom_pixmap = new QPixmap(720 - TEXT_MARGIN, 20);
-
- for(int x = 0; x < 720 - TEXT_MARGIN; x++) {
- for(int y = 0; y < 20; y++) {
- top_grey[x][y] = 255;
- }
- }
-
- for(int x = 0; x < 720 - TEXT_MARGIN; x++) {
- for(int y = 0; y < 20; y++) {
- bottom_grey[x][y] = 255;
- }
- }
-
- img_muted = loadIcon(PIXMAP_MUTE, ICON_HEIGHT);
- img_unmuted = loadIcon(PIXMAP_UNMUTE, ICON_HEIGHT);
-}
-
-YUVDraw::~YUVDraw()
-{
- delete top_pixmap;
- delete bottom_pixmap;
-}
-
-void YUVDraw::setOverlay(SDL_Overlay* o)
-{
- overlay = o;
-}
-
-void YUVDraw::addPixel(int x, int y, int val)
-{
- if(overlay->w < x) return; // Out of range
- if(overlay->h < y) return; // Out of range
-
- Uint8 **pixels = overlay->pixels;
- Uint16 *pitches = overlay->pitches;
-
- Uint8* pixel = &pixels[0][(2 * x) + (y * pitches[0])];
-
- if(val > 0) *pixel = (255<*pixel+val?255:*pixel+val);
- else *pixel = (0>*pixel+val?0:*pixel+val);
-}
-
-
-void YUVDraw::setTopText(char* text)
-{
- miav_app->lock();
- top_pixmap->fill();
-
- QPainter painter;
- painter.begin(top_pixmap);
- painter.setFont( QFont( "Arial", 12, QFont::Bold ) );
- painter.setPen( Qt::black );
- painter.drawText(64, 15, text);
- painter.end();
-
- QImage image = top_pixmap->convertToImage();
-
- 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));
- }
- }
- miav_app->unlock();
-}
-
-void YUVDraw::setBottomText(char* text)
-{
- miav_app->lock();
- bottom_pixmap->fill();
-
- QPainter painter;
- painter.begin(bottom_pixmap);
- painter.setFont( QFont( "Arial", 12, QFont::Bold ) );
- painter.setPen( Qt::black );
- painter.drawText(0, 15, text);
- painter.end();
-
- QImage image = bottom_pixmap->convertToImage();
-
- for(int x = 0; x < 720 - TEXT_MARGIN; x++) {
- for(int y = 0; y < 20; y++) {
- bottom_grey[x][y] = qGray(image.pixel(x, y));
- }
- }
- miav_app->unlock();
-}
-
-void YUVDraw::draw()
-{
- for(int x = 0; x < 720 - TEXT_MARGIN; x++) {
- for(int y = 0; y < 20; y++) {
- if(top_grey[x][y] != 255) addPixel(x + TEXT_MARGIN, y + TEXT_MARGIN, 255 - top_grey[x][y]);
- }
- }
-
- for(int x = 0; x < 720 - TEXT_MARGIN; x++) {
- for(int y = 0; y < 20; y++) {
- if(bottom_grey[x][y] != 255) addPixel(x + TEXT_MARGIN, (556 - TEXT_MARGIN)+ y, 255 - bottom_grey[x][y]);
- }
- }
-}
-
-void YUVDraw::mute(bool muted)
-{
- int xoffset = 0;
- int yoffset = 0;
-
- QImage *img;
- if(muted) img = img_muted;
- else img = img_unmuted;
-
- // Swicth the bool and draw an mute/unmute symbol
- 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);
- }
- }
-}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-/*
-void YUVDraw::setText(int xoffset, int yoffset, char* text, int val)
-{
- for(unsigned int i = 0; i < strlen(text); i++) {
- for(int x = 0; x < FONT_WIDTH; x++) {
- for(int y = 0; y < FONT_HEIGHT; y++) {
- unsigned char col = palette[letter[(int)text[i]][y][x]];
- if(col) col += val;
- addPixel(i * FONT_WIDTH + x + xoffset, y + yoffset, col);
- }
- }
- }
-}
-*/
-
-/*
-typedef struct{
- Uint32 format;
- int w, h;
- int planes;
- Uint16 *pitches;
- Uint8 **pixels;
- Uint32 hw_overlay:1;
-} SDL_Overlay;
-*/
-
-#endif/*USE_GUI*/