diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | e2de64d6f1beb9e492daf5b886e19933c1fa41dd (patch) | |
tree | 9047cf9e6b5c43878d5bf82660adae77ceee097a /mpeglib/lib/util/render/sdl/imageDeskSDL.cpp | |
download | tdemultimedia-e2de64d6f1beb9e492daf5b886e19933c1fa41dd.tar.gz tdemultimedia-e2de64d6f1beb9e492daf5b886e19933c1fa41dd.zip |
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdemultimedia@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'mpeglib/lib/util/render/sdl/imageDeskSDL.cpp')
-rw-r--r-- | mpeglib/lib/util/render/sdl/imageDeskSDL.cpp | 110 |
1 files changed, 110 insertions, 0 deletions
diff --git a/mpeglib/lib/util/render/sdl/imageDeskSDL.cpp b/mpeglib/lib/util/render/sdl/imageDeskSDL.cpp new file mode 100644 index 00000000..b1ff9a7c --- /dev/null +++ b/mpeglib/lib/util/render/sdl/imageDeskSDL.cpp @@ -0,0 +1,110 @@ +/* + SDL surface output + Copyright (C) 2000 Martin Vogt + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU Library General Public License as published by + the Free Software Foundation. + + For more information look at the file COPYRIGHT in this package + + */ + + +#include "imageDeskSDL.h" + +#ifdef SDL_WRAPPER + + +ImageDeskSDL::ImageDeskSDL() { + + this->surface=NULL; + this->rect=NULL; + imageMode=_IMAGE_NONE; + lSupport=true; + image=NULL; +} + + +ImageDeskSDL::~ImageDeskSDL() { + closeImage(); + cout << "SDL destry needed"<<endl; +} + + + +int ImageDeskSDL::support() { + return lSupport; +} + + +void ImageDeskSDL::init(XWindow* xWindow, YUVPicture* pic) { + cout << "ImageDeskSDL::init"<<endl; + this->surface=(SDL_Surface*)xWindow; + this->rect=(SDL_Rect*)pic; +} + +int ImageDeskSDL::openImage(int imageMode) { + int w=rect->w; + int h=rect->h; + this->imageMode=imageMode; + /* Create a YV12 image (Y + V + U) */ + cout << "CreateYUVOverlay -s"<<imageMode<<" w:"<<w<<" h:"<<h<<endl; + image = SDL_CreateYUVOverlay(w,h, + SDL_YV12_OVERLAY, + surface); + if (image == NULL) { + cout << "error creating image"<<endl; + exit(0); + } + cout << "CreateYUVOverlay -e"<<endl; + return true; +} + + +int ImageDeskSDL::closeImage() { + if (image != NULL) { + cout << "FreeYUVOverlay -s"<<endl; + SDL_FreeYUVOverlay(image); + // otherwise test of NULL will fail + image = NULL; + cout << "FreeYUVOverlay -e"<<endl; + } + return true; +} + + + +void ImageDeskSDL::ditherImage(YUVPicture* pic) { + + int w=pic->getWidth(); + int h=pic->getHeight(); + int size=w*h+(w*h)/2; + SDL_LockYUVOverlay(image); + memcpy(*((char**)image->pixels),pic->getLuminancePtr(),size); + SDL_UnlockYUVOverlay(image); + +} + + +void ImageDeskSDL::putImage(int w, int h) { + SDL_Rect dest; + dest.x=0; + dest.y=0; + dest.w=rect->w; + dest.h=rect->h; + if (imageMode & _IMAGE_RESIZE) { + dest.w = w; + dest.h = h; + } + + if (imageMode & _IMAGE_DOUBLE) { + dest.w*=2; + dest.h*=2; + } + SDL_DisplayYUVOverlay(image,&dest); + +} + +#endif + |