Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

plfiltervideoinvert.cpp

Go to the documentation of this file.
00001 /*
00002 /--------------------------------------------------------------------
00003 |
00004 |      $Id: plfiltervideoinvert.cpp,v 1.1 2004/05/21 21:02:53 maxx Exp $
00005 |
00006 |      Copyright (c) 1996-1998 Ulrich von Zadow
00007 |
00008 \--------------------------------------------------------------------
00009 */
00010 
00011 #include "plstdpch.h"
00012 #include "plfilter.h"
00013 #include "plfiltervideoinvert.h"
00014 #include "plbitmap.h"
00015 #include "plhsvconvert.h"
00016 
00018 // Construction/Destruction
00020 
00021 
00022 PLFilterVideoInvert::PLFilterVideoInvert() : PLFilter()
00023 {
00024 
00025 }
00026 
00027 PLFilterVideoInvert::~PLFilterVideoInvert()
00028 {
00029 
00030 }
00031 
00032 void PLFilterVideoInvert::Apply(PLBmp *pBmpSource, PLBmp *pBmpDest) const
00033 {
00034   // Only works for 32 bpp bitmaps at the moment.
00035   PLASSERT (pBmpSource->GetBitsPerPixel() == 32);
00036 
00037   pBmpDest->Create (pBmpSource->GetWidth(), pBmpSource->GetHeight(),
00038                     32, false, pBmpSource->GetResolution());
00039   PLBYTE ** pSrcLines = pBmpSource->GetLineArray();
00040   PLBYTE ** pDstLines = pBmpDest->GetLineArray();
00041 
00042   for (int y = 0; y<pBmpDest->GetHeight(); ++y)
00043   { // For each line
00044     PLBYTE * pSrcPixel = pSrcLines[y];
00045     PLBYTE * pDstPixel = pDstLines[y];
00046 
00047     for (int x = 0; x < pBmpDest->GetWidth(); ++x)
00048     { // For each pixel
00049       double v1, v2, v3;
00050 
00051       v1 = (double)pSrcPixel[PL_RGBA_RED];
00052       v2 = (double)pSrcPixel[PL_RGBA_GREEN];
00053       v3 = (double)pSrcPixel[PL_RGBA_BLUE];
00054 
00055       fp_rgb_to_hsv(&v1, &v2, &v3);
00056       v3 = 255.0-v3;
00057       fp_hsv_to_rgb(&v1, &v2, &v3);
00058 
00059       *pDstPixel = (int)v3;
00060     pDstPixel++;
00061       *pDstPixel = (int)v2;
00062     pDstPixel++;
00063       *pDstPixel = (int)v1;
00064     pDstPixel++;
00065 
00066     pDstPixel++;
00067 
00068     /*PLBYTE (pSrcPixel[PL_RGBA_RED]*0.212671+
00069                          pSrcPixel[PL_RGBA_GREEN]*0.715160+
00070                          pSrcPixel[PL_RGBA_BLUE]*0.072169);*/
00071       pSrcPixel += sizeof(PLPixel32);
00072     }
00073   }
00074 
00075 }
00076 
00077 /*
00078 /--------------------------------------------------------------------
00079 |
00080 |      $Log: plfiltervideoinvert.cpp,v $
00081 |      Revision 1.1  2004/05/21 21:02:53  maxx
00082 |      Initial Version of vuVolume, moderatly changed to make it compile on my windows and linux machine.
00083 |
00084 |      Revision 1.1  2002/11/13 01:59:48  mspindle
00085 |      *** empty log message ***
00086 |
00087 |      Revision 1.3  2001/10/16 17:12:27  uzadow
00088 |      Added support for resolution information (Luca Piergentili)
00089 |
00090 |      Revision 1.2  2001/10/06 22:37:08  uzadow
00091 |      Linux compatibility.
00092 |
00093 |      Revision 1.1  2001/09/16 19:03:23  uzadow
00094 |      Added global name prefix PL, changed most filenames.
00095 |
00096 |      Revision 1.5  2001/02/04 14:31:52  uzadow
00097 |      Member initialization list cleanup (Erik Hoffmann).
00098 |
00099 |      Revision 1.4  2001/01/15 15:05:31  uzadow
00100 |      Added PLBmp::ApplyFilter() and PLBmp::CreateFilteredCopy()
00101 |
00102 |      Revision 1.3  2000/12/18 22:42:53  uzadow
00103 |      Replaced RGBAPIXEL with PLPixel32.
00104 |
00105 |      Revision 1.2  2000/10/12 21:56:12  uzadow
00106 |      Moved local functions from VideoInvertFilter.cpp to
00107 |      hsvconvert.*
00108 |
00109 |      Revision 1.1  2000/03/31 12:20:06  Ulrich von Zadow
00110 |      Video invert filter (beta)
00111 |
00112 |
00113 |
00114 \--------------------------------------------------------------------
00115 */

Generated on Wed Dec 15 21:20:30 2004 for vuVolume by  doxygen 1.3.9.1