00001
00002
00003
00004
00005
00006
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
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
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 {
00044 PLBYTE * pSrcPixel = pSrcLines[y];
00045 PLBYTE * pDstPixel = pDstLines[y];
00046
00047 for (int x = 0; x < pBmpDest->GetWidth(); ++x)
00048 {
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
00069
00070
00071 pSrcPixel += sizeof(PLPixel32);
00072 }
00073 }
00074
00075 }
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115