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

plfilterthreshold.cpp

Go to the documentation of this file.
00001 /*
00002 /--------------------------------------------------------------------
00003 |
00004 |      $Id: plfilterthreshold.cpp,v 1.1 2004/05/21 21:02:53 maxx Exp $
00005 |
00006 |      Copyright (c) 2000-2001 Iyad Hatem
00007 |
00008 \--------------------------------------------------------------------
00009 */
00010 
00011 #include "plstdpch.h"
00012 #include "plfilterthreshold.h"
00013 #include "plbitmap.h"
00014 
00015 
00017 // Construction/Destruction
00019 
00020 
00021 PLFilterThreshold::PLFilterThreshold(int threshold_min,int threshold_max, int channel)
00022 : PLFilter(),
00023   m_threshold_min(threshold_min),
00024   m_threshold_max(threshold_max),
00025   m_channel(channel)
00026 {
00027 }
00028 
00029 PLFilterThreshold::~PLFilterThreshold()
00030 {
00031 
00032 }
00033 
00034 void PLFilterThreshold::Apply(PLBmp * pBmpSource, PLBmp * pBmpDest) const
00035 {
00036 
00037   int threshold_min = m_threshold_min;
00038   int threshold_max = m_threshold_max;
00039   int channel = m_channel;
00040 
00041   // Only works for 32 bpp bitmaps at the moment.
00042   PLASSERT (pBmpSource->GetBitsPerPixel() == 32);
00043 
00044   pBmpDest->Create (pBmpSource->GetWidth(), pBmpSource->GetHeight(), 8,
00045                     false, pBmpSource->GetResolution());
00046   PLBYTE ** pSrcLines = pBmpSource->GetLineArray();
00047   PLBYTE ** pDstLines = pBmpDest->GetLineArray();
00048 
00049   for (int y = 0; y<pBmpDest->GetHeight(); ++y)
00050   { // For each line
00051     PLBYTE * pSrcPixel = pSrcLines[y];
00052     PLBYTE * pDstPixel = pDstLines[y];
00053 
00054     for (int x = 0; x < pBmpDest->GetWidth(); ++x)
00055     { // For each pixel
00056       if ((PLBYTE (pSrcPixel[channel]) <= PLBYTE (threshold_min)) ||
00057           (PLBYTE (pSrcPixel[channel]) >= PLBYTE(threshold_max)))
00058         *pDstPixel = 0;
00059       else
00060         *pDstPixel = pSrcPixel[channel];
00061       pSrcPixel += sizeof(PLPixel32);
00062       ++pDstPixel;
00063     }
00064   }
00065 }
00066 
00067 /*
00068 /--------------------------------------------------------------------
00069 |
00070 |      $Log: plfilterthreshold.cpp,v $
00071 |      Revision 1.1  2004/05/21 21:02:53  maxx
00072 |      Initial Version of vuVolume, moderatly changed to make it compile on my windows and linux machine.
00073 |
00074 |      Revision 1.1  2002/11/13 01:59:48  mspindle
00075 |      *** empty log message ***
00076 |
00077 |      Revision 1.4  2001/10/21 17:12:40  uzadow
00078 |      Added PSD decoder beta, removed BPPWanted from all decoders, added PLFilterPixel.
00079 |
00080 |      Revision 1.3  2001/10/16 17:12:27  uzadow
00081 |      Added support for resolution information (Luca Piergentili)
00082 |
00083 |      Revision 1.2  2001/10/06 22:37:08  uzadow
00084 |      Linux compatibility.
00085 |
00086 |      Revision 1.1  2001/09/16 19:03:23  uzadow
00087 |      Added global name prefix PL, changed most filenames.
00088 |
00089 |      Revision 1.4  2001/02/04 14:31:52  uzadow
00090 |      Member initialization list cleanup (Erik Hoffmann).
00091 |
00092 |      Revision 1.3  2001/01/15 15:05:31  uzadow
00093 |      Added PLBmp::ApplyFilter() and PLBmp::CreateFilteredCopy()
00094 |
00095 |      Revision 1.2  2000/12/18 22:42:53  uzadow
00096 |      Replaced RGBAPIXEL with PLPixel32.
00097 |
00098 |      Revision 1.1  2000/09/26 14:28:47  Administrator
00099 |      Added Threshold filter
00100 |
00101 |
00102 |
00103 \--------------------------------------------------------------------
00104 */

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