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

plfiltercrop.cpp

Go to the documentation of this file.
00001 /*
00002 /--------------------------------------------------------------------
00003 |
00004 |      $Id: plfiltercrop.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 "plfiltercrop.h"
00013 #include "plbitmap.h"
00014 
00015 
00016 PLFilterCrop::PLFilterCrop(int XMin, int YMin, int XMax, int YMax)
00017   : PLFilter(),
00018     m_XMin(XMin),
00019     m_XMax(XMax),
00020     m_YMin(YMin),
00021     m_YMax(YMax)
00022 {
00023 }
00024 
00025 PLFilterCrop::~PLFilterCrop()
00026 {
00027 
00028 }
00029 
00030 void PLFilterCrop::Apply(PLBmp * pBmpSource, PLBmp * pBmpDest) const
00031 {
00032   PLASSERT (m_XMin >= 0);
00033   PLASSERT (m_XMax <= pBmpSource->GetWidth());
00034   PLASSERT (m_YMin >= 0);
00035   PLASSERT (m_YMax <= pBmpSource->GetHeight());
00036   PLASSERT (m_XMin < m_XMax);
00037   PLASSERT (m_YMin < m_YMax);
00038   // Only 8, 24 and 32 bpp supported for now.
00039   PLASSERT (pBmpSource->GetBitsPerPixel() == 8 ||
00040             pBmpSource->GetBitsPerPixel() == 24 ||
00041             pBmpSource->GetBitsPerPixel() == 32);
00042 
00043   pBmpDest->Create (m_XMax-m_XMin, m_YMax-m_YMin,
00044                     pBmpSource->GetBitsPerPixel(), pBmpSource->HasAlpha(),
00045                     pBmpSource->GetResolution());
00046   PLBYTE ** pSrcLineArray = pBmpSource->GetLineArray();
00047   PLBYTE ** pDstLineArray = pBmpDest->GetLineArray();
00048 
00049   int y;
00050   for (y = m_YMin; y < m_YMax; y++)
00051   {
00052     PLBYTE * pSrcLine = pSrcLineArray[y];
00053     PLBYTE * pDstLine = pDstLineArray[y-m_YMin];
00054     int BytesPerPixel = pBmpSource->GetBitsPerPixel()/8;
00055     memcpy (pDstLine, pSrcLine + m_XMin*BytesPerPixel, (m_XMax-m_XMin)*BytesPerPixel);
00056   }
00057   if (pBmpSource->GetBitsPerPixel() == 8)
00058   {
00059     pBmpDest->SetPalette(pBmpSource->GetPalette());
00060   }
00061 }
00062 
00063 /*
00064 /--------------------------------------------------------------------
00065 |
00066 |      $Log: plfiltercrop.cpp,v $
00067 |      Revision 1.1  2004/05/21 21:02:53  maxx
00068 |      Initial Version of vuVolume, moderatly changed to make it compile on my windows and linux machine.
00069 |
00070 |      Revision 1.1  2002/11/13 01:59:47  mspindle
00071 |      *** empty log message ***
00072 |
00073 |      Revision 1.5  2001/10/16 17:12:26  uzadow
00074 |      Added support for resolution information (Luca Piergentili)
00075 |
00076 |      Revision 1.4  2001/10/06 22:37:08  uzadow
00077 |      Linux compatibility.
00078 |
00079 |      Revision 1.3  2001/09/30 19:55:37  uzadow
00080 |      Fixed bug for 8 bpp in PLFilterCrop.
00081 |
00082 |      Revision 1.2  2001/09/28 19:50:56  uzadow
00083 |      Added some 24 bpp stuff & other minor features.
00084 |
00085 |      Revision 1.1  2001/09/16 19:03:23  uzadow
00086 |      Added global name prefix PL, changed most filenames.
00087 |
00088 |      Revision 1.7  2001/02/04 14:31:52  uzadow
00089 |      Member initialization list cleanup (Erik Hoffmann).
00090 |
00091 |      Revision 1.6  2001/01/15 15:05:31  uzadow
00092 |      Added PLBmp::ApplyFilter() and PLBmp::CreateFilteredCopy()
00093 |
00094 |      Revision 1.5  2000/09/26 10:47:26  Administrator
00095 |      no message
00096 |
00097 |      Revision 1.4  2000/01/16 20:43:15  anonymous
00098 |      Removed MFC dependencies
00099 |
00100 |      Revision 1.3  1999/12/08 16:31:40  Ulrich von Zadow
00101 |      Unix compatibility
00102 |
00103 |      Revision 1.2  1999/10/21 18:48:03  Ulrich von Zadow
00104 |      no message
00105 |
00106 |      Revision 1.1  1999/10/21 16:05:17  Ulrich von Zadow
00107 |      Moved filters to separate directory. Added Crop, Grayscale and
00108 |      GetAlpha filters.
00109 |
00110 |      Revision 1.1  1999/10/19 21:29:44  Ulrich von Zadow
00111 |      Added filters.
00112 |
00113 |
00114 \--------------------------------------------------------------------
00115 */

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