Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 592446 | Differences between
and this patch

Collapse All | Expand All

(-)a/lib/cximage-6.0/CxImage/ximadef.h (-4 / +4 lines)
Lines 53-63 Link Here
53
 #define CXIMAGE_SUPPORT_WINDOWS 0
53
 #define CXIMAGE_SUPPORT_WINDOWS 0
54
#endif
54
#endif
55
55
56
#ifndef min
56
#ifndef __min
57
#define min(a,b) (((a)<(b))?(a):(b))
57
#define __min(a,b) (((a)<(b))?(a):(b))
58
#endif
58
#endif
59
#ifndef max
59
#ifndef __max
60
#define max(a,b) (((a)>(b))?(a):(b))
60
#define __max(a,b) (((a)>(b))?(a):(b))
61
#endif
61
#endif
62
62
63
#ifndef PI
63
#ifndef PI
(-)a/lib/cximage-6.0/CxImage/ximadsp.cpp (-90 / +90 lines)
Lines 389-396 RGBQUAD CxImage::RGBtoHSL(RGBQUAD lRGBColor) Link Here
389
	G = lRGBColor.rgbGreen;
389
	G = lRGBColor.rgbGreen;
390
	B = lRGBColor.rgbBlue;
390
	B = lRGBColor.rgbBlue;
391
391
392
	cMax = max( max(R,G), B);	/* calculate lightness */
392
	cMax = __max( __max(R,G), B);	/* calculate lightness */
393
	cMin = min( min(R,G), B);
393
	cMin = __min( __min(R,G), B);
394
	L = (BYTE)((((cMax+cMin)*HSLMAX)+RGBMAX)/(2*RGBMAX));
394
	L = (BYTE)((((cMax+cMin)*HSLMAX)+RGBMAX)/(2*RGBMAX));
395
395
396
	if (cMax==cMin){			/* r=g=b --> achromatic case */
396
	if (cMax==cMin){			/* r=g=b --> achromatic case */
Lines 489-497 RGBQUAD CxImage::YUVtoRGB(RGBQUAD lYUVColor) Link Here
489
	G = (int)( Y - 0.344f * U - 0.714f * V);
489
	G = (int)( Y - 0.344f * U - 0.714f * V);
490
	B = (int)( Y + 1.770f * U);
490
	B = (int)( Y + 1.770f * U);
491
491
492
	R= min(255,max(0,R));
492
	R= __min(255,__max(0,R));
493
	G= min(255,max(0,G));
493
	G= __min(255,__max(0,G));
494
	B= min(255,max(0,B));
494
	B= __min(255,__max(0,B));
495
	RGBQUAD rgb={(BYTE)B,(BYTE)G,(BYTE)R,0};
495
	RGBQUAD rgb={(BYTE)B,(BYTE)G,(BYTE)R,0};
496
	return rgb;
496
	return rgb;
497
}
497
}
Lines 510-518 RGBQUAD CxImage::RGBtoYUV(RGBQUAD lRGBColor) Link Here
510
	U = (int)((B-Y) * 0.565f + 128);
510
	U = (int)((B-Y) * 0.565f + 128);
511
	V = (int)((R-Y) * 0.713f + 128);
511
	V = (int)((R-Y) * 0.713f + 128);
512
512
513
	Y= min(255,max(0,Y));
513
	Y= __min(255,__max(0,Y));
514
	U= min(255,max(0,U));
514
	U= __min(255,__max(0,U));
515
	V= min(255,max(0,V));
515
	V= __min(255,__max(0,V));
516
	RGBQUAD yuv={(BYTE)V,(BYTE)U,(BYTE)Y,0};
516
	RGBQUAD yuv={(BYTE)V,(BYTE)U,(BYTE)Y,0};
517
	return yuv;
517
	return yuv;
518
}
518
}
Lines 528-536 RGBQUAD CxImage::YIQtoRGB(RGBQUAD lYIQColor) Link Here
528
	G = (int)( Y - 0.273f * I - 0.647f * Q);
528
	G = (int)( Y - 0.273f * I - 0.647f * Q);
529
	B = (int)( Y - 1.104f * I + 1.701f * Q);
529
	B = (int)( Y - 1.104f * I + 1.701f * Q);
530
530
531
	R= min(255,max(0,R));
531
	R= __min(255,__max(0,R));
532
	G= min(255,max(0,G));
532
	G= __min(255,__max(0,G));
533
	B= min(255,max(0,B));
533
	B= __min(255,__max(0,B));
534
	RGBQUAD rgb={(BYTE)B,(BYTE)G,(BYTE)R,0};
534
	RGBQUAD rgb={(BYTE)B,(BYTE)G,(BYTE)R,0};
535
	return rgb;
535
	return rgb;
536
}
536
}
Lines 546-554 RGBQUAD CxImage::RGBtoYIQ(RGBQUAD lRGBColor) Link Here
546
	I = (int)( 0.5960f * R - 0.2742f * G - 0.3219f * B + 128);
546
	I = (int)( 0.5960f * R - 0.2742f * G - 0.3219f * B + 128);
547
	Q = (int)( 0.2109f * R - 0.5229f * G + 0.3120f * B + 128);
547
	Q = (int)( 0.2109f * R - 0.5229f * G + 0.3120f * B + 128);
548
548
549
	Y= min(255,max(0,Y));
549
	Y= __min(255,__max(0,Y));
550
	I= min(255,max(0,I));
550
	I= __min(255,__max(0,I));
551
	Q= min(255,max(0,Q));
551
	Q= __min(255,__max(0,Q));
552
	RGBQUAD yiq={(BYTE)Q,(BYTE)I,(BYTE)Y,0};
552
	RGBQUAD yiq={(BYTE)Q,(BYTE)I,(BYTE)Y,0};
553
	return yiq;
553
	return yiq;
554
}
554
}
Lines 565-573 RGBQUAD CxImage::XYZtoRGB(RGBQUAD lXYZColor) Link Here
565
	G = (int)( -0.969256f * X + 1.875992f * Y + 0.041556f * Z * k);
565
	G = (int)( -0.969256f * X + 1.875992f * Y + 0.041556f * Z * k);
566
	B = (int)(  0.055648f * X - 0.204043f * Y + 1.057311f * Z * k);
566
	B = (int)(  0.055648f * X - 0.204043f * Y + 1.057311f * Z * k);
567
567
568
	R= min(255,max(0,R));
568
	R= __min(255,__max(0,R));
569
	G= min(255,max(0,G));
569
	G= __min(255,__max(0,G));
570
	B= min(255,max(0,B));
570
	B= __min(255,__max(0,B));
571
	RGBQUAD rgb={(BYTE)B,(BYTE)G,(BYTE)R,0};
571
	RGBQUAD rgb={(BYTE)B,(BYTE)G,(BYTE)R,0};
572
	return rgb;
572
	return rgb;
573
}
573
}
Lines 583-591 RGBQUAD CxImage::RGBtoXYZ(RGBQUAD lRGBColor) Link Here
583
	Y = (int)( 0.212671f * R + 0.715160f * G + 0.072169f * B);
583
	Y = (int)( 0.212671f * R + 0.715160f * G + 0.072169f * B);
584
	Z = (int)((0.019334f * R + 0.119193f * G + 0.950227f * B)*0.918483657f);
584
	Z = (int)((0.019334f * R + 0.119193f * G + 0.950227f * B)*0.918483657f);
585
585
586
	//X= min(255,max(0,X));
586
	//X= __min(255,__max(0,X));
587
	//Y= min(255,max(0,Y));
587
	//Y= __min(255,__max(0,Y));
588
	//Z= min(255,max(0,Z));
588
	//Z= __min(255,__max(0,Z));
589
	RGBQUAD xyz={(BYTE)Z,(BYTE)Y,(BYTE)X,0};
589
	RGBQUAD xyz={(BYTE)Z,(BYTE)Y,(BYTE)X,0};
590
	return xyz;
590
	return xyz;
591
}
591
}
Lines 707-713 bool CxImage::Light(long brightness, long contrast) Link Here
707
707
708
	BYTE cTable[256]; //<nipper>
708
	BYTE cTable[256]; //<nipper>
709
	for (int i=0;i<256;i++)	{
709
	for (int i=0;i<256;i++)	{
710
		cTable[i] = (BYTE)max(0,min(255,(int)((i-128)*c + brightness + 0.5f)));
710
		cTable[i] = (BYTE)__max(0,__min(255,(int)((i-128)*c + brightness + 0.5f)));
711
	}
711
	}
712
712
713
	return Lut(cTable);
713
	return Lut(cTable);
Lines 830-840 bool CxImage::Filter(long* kernel, long Ksize, long Kfactor, long Koffset) Link Here
830
						}
830
						}
831
					}
831
					}
832
					if (Kfactor==0 || ksumcur==0){
832
					if (Kfactor==0 || ksumcur==0){
833
						cPtr2[iY1] = (BYTE)min(255, max(0,(int)(b + Koffset)));
833
						cPtr2[iY1] = (BYTE)__min(255, __max(0,(int)(b + Koffset)));
834
					} else if (ksumtot == ksumcur) {
834
					} else if (ksumtot == ksumcur) {
835
						cPtr2[iY1] = (BYTE)min(255, max(0,(int)(b/Kfactor + Koffset)));
835
						cPtr2[iY1] = (BYTE)__min(255, __max(0,(int)(b/Kfactor + Koffset)));
836
					} else {
836
					} else {
837
						cPtr2[iY1] = (BYTE)min(255, max(0,(int)((b*ksumtot)/(ksumcur*Kfactor) + Koffset)));
837
						cPtr2[iY1] = (BYTE)__min(255, __max(0,(int)((b*ksumtot)/(ksumcur*Kfactor) + Koffset)));
838
					}
838
					}
839
				}
839
				}
840
			}
840
			}
Lines 863-879 bool CxImage::Filter(long* kernel, long Ksize, long Kfactor, long Koffset) Link Here
863
						}
863
						}
864
					}
864
					}
865
					if (Kfactor==0 || ksumcur==0){
865
					if (Kfactor==0 || ksumcur==0){
866
						c.rgbRed   = (BYTE)min(255, max(0,(int)(r + Koffset)));
866
						c.rgbRed   = (BYTE)__min(255, __max(0,(int)(r + Koffset)));
867
						c.rgbGreen = (BYTE)min(255, max(0,(int)(g + Koffset)));
867
						c.rgbGreen = (BYTE)__min(255, __max(0,(int)(g + Koffset)));
868
						c.rgbBlue  = (BYTE)min(255, max(0,(int)(b + Koffset)));
868
						c.rgbBlue  = (BYTE)__min(255, __max(0,(int)(b + Koffset)));
869
					} else if (ksumtot == ksumcur) {
869
					} else if (ksumtot == ksumcur) {
870
						c.rgbRed   = (BYTE)min(255, max(0,(int)(r/Kfactor + Koffset)));
870
						c.rgbRed   = (BYTE)__min(255, __max(0,(int)(r/Kfactor + Koffset)));
871
						c.rgbGreen = (BYTE)min(255, max(0,(int)(g/Kfactor + Koffset)));
871
						c.rgbGreen = (BYTE)__min(255, __max(0,(int)(g/Kfactor + Koffset)));
872
						c.rgbBlue  = (BYTE)min(255, max(0,(int)(b/Kfactor + Koffset)));
872
						c.rgbBlue  = (BYTE)__min(255, __max(0,(int)(b/Kfactor + Koffset)));
873
					} else {
873
					} else {
874
						c.rgbRed   = (BYTE)min(255, max(0,(int)((r*ksumtot)/(ksumcur*Kfactor) + Koffset)));
874
						c.rgbRed   = (BYTE)__min(255, __max(0,(int)((r*ksumtot)/(ksumcur*Kfactor) + Koffset)));
875
						c.rgbGreen = (BYTE)min(255, max(0,(int)((g*ksumtot)/(ksumcur*Kfactor) + Koffset)));
875
						c.rgbGreen = (BYTE)__min(255, __max(0,(int)((g*ksumtot)/(ksumcur*Kfactor) + Koffset)));
876
						c.rgbBlue  = (BYTE)min(255, max(0,(int)((b*ksumtot)/(ksumcur*Kfactor) + Koffset)));
876
						c.rgbBlue  = (BYTE)__min(255, __max(0,(int)((b*ksumtot)/(ksumcur*Kfactor) + Koffset)));
877
					}
877
					}
878
					tmp.BlindSetPixelColor(x,y,c);
878
					tmp.BlindSetPixelColor(x,y,c);
879
				}
879
				}
Lines 1078-1085 bool CxImage::Edge(long Ksize) Link Here
1078
// 
1078
// 
1079
void CxImage::Mix(CxImage & imgsrc2, ImageOpType op, long lXOffset, long lYOffset, bool bMixAlpha)
1079
void CxImage::Mix(CxImage & imgsrc2, ImageOpType op, long lXOffset, long lYOffset, bool bMixAlpha)
1080
{
1080
{
1081
    long lWide = min(GetWidth(),imgsrc2.GetWidth()-lXOffset);
1081
    long lWide = __min(GetWidth(),imgsrc2.GetWidth()-lXOffset);
1082
    long lHeight = min(GetHeight(),imgsrc2.GetHeight()-lYOffset);
1082
    long lHeight = __min(GetHeight(),imgsrc2.GetHeight()-lYOffset);
1083
1083
1084
	bool bEditAlpha = imgsrc2.AlphaIsValid() & bMixAlpha;
1084
	bool bEditAlpha = imgsrc2.AlphaIsValid() & bMixAlpha;
1085
1085
Lines 1112-1127 void CxImage::Mix(CxImage & imgsrc2, ImageOpType op, long lXOffset, long lYOffse Link Here
1112
						if (bEditAlpha) rgbDest.rgbReserved = (BYTE)((rgb1.rgbReserved+rgb2.rgbReserved)/2);
1112
						if (bEditAlpha) rgbDest.rgbReserved = (BYTE)((rgb1.rgbReserved+rgb2.rgbReserved)/2);
1113
					break;
1113
					break;
1114
					case OpAdd:
1114
					case OpAdd:
1115
						rgbDest.rgbBlue = (BYTE)max(0,min(255,rgb1.rgbBlue+rgb2.rgbBlue));
1115
						rgbDest.rgbBlue = (BYTE)__max(0,__min(255,rgb1.rgbBlue+rgb2.rgbBlue));
1116
						rgbDest.rgbGreen = (BYTE)max(0,min(255,rgb1.rgbGreen+rgb2.rgbGreen));
1116
						rgbDest.rgbGreen = (BYTE)__max(0,__min(255,rgb1.rgbGreen+rgb2.rgbGreen));
1117
						rgbDest.rgbRed = (BYTE)max(0,min(255,rgb1.rgbRed+rgb2.rgbRed));
1117
						rgbDest.rgbRed = (BYTE)__max(0,__min(255,rgb1.rgbRed+rgb2.rgbRed));
1118
						if (bEditAlpha) rgbDest.rgbReserved = (BYTE)max(0,min(255,rgb1.rgbReserved+rgb2.rgbReserved));
1118
						if (bEditAlpha) rgbDest.rgbReserved = (BYTE)__max(0,__min(255,rgb1.rgbReserved+rgb2.rgbReserved));
1119
					break;
1119
					break;
1120
					case OpSub:
1120
					case OpSub:
1121
						rgbDest.rgbBlue = (BYTE)max(0,min(255,rgb1.rgbBlue-rgb2.rgbBlue));
1121
						rgbDest.rgbBlue = (BYTE)__max(0,__min(255,rgb1.rgbBlue-rgb2.rgbBlue));
1122
						rgbDest.rgbGreen = (BYTE)max(0,min(255,rgb1.rgbGreen-rgb2.rgbGreen));
1122
						rgbDest.rgbGreen = (BYTE)__max(0,__min(255,rgb1.rgbGreen-rgb2.rgbGreen));
1123
						rgbDest.rgbRed = (BYTE)max(0,min(255,rgb1.rgbRed-rgb2.rgbRed));
1123
						rgbDest.rgbRed = (BYTE)__max(0,__min(255,rgb1.rgbRed-rgb2.rgbRed));
1124
						if (bEditAlpha) rgbDest.rgbReserved = (BYTE)max(0,min(255,rgb1.rgbReserved-rgb2.rgbReserved));
1124
						if (bEditAlpha) rgbDest.rgbReserved = (BYTE)__max(0,__min(255,rgb1.rgbReserved-rgb2.rgbReserved));
1125
					break;
1125
					break;
1126
					case OpAnd:
1126
					case OpAnd:
1127
						rgbDest.rgbBlue = (BYTE)(rgb1.rgbBlue&rgb2.rgbBlue);
1127
						rgbDest.rgbBlue = (BYTE)(rgb1.rgbBlue&rgb2.rgbBlue);
Lines 1202-1212 void CxImage::Mix(CxImage & imgsrc2, ImageOpType op, long lXOffset, long lYOffse Link Here
1202
							double dSmallAmt = dSmall*((double)rgb2.rgbBlue);
1202
							double dSmallAmt = dSmall*((double)rgb2.rgbBlue);
1203
1203
1204
							if( lAverage < lThresh+1){
1204
							if( lAverage < lThresh+1){
1205
								rgbDest.rgbBlue = (BYTE)max(0,min(255,(int)(dLarge*((double)rgb1.rgbBlue) +
1205
								rgbDest.rgbBlue = (BYTE)__max(0,__min(255,(int)(dLarge*((double)rgb1.rgbBlue) +
1206
												dSmallAmt)));
1206
												dSmallAmt)));
1207
								rgbDest.rgbGreen = (BYTE)max(0,min(255,(int)(dLarge*((double)rgb1.rgbGreen) +
1207
								rgbDest.rgbGreen = (BYTE)__max(0,__min(255,(int)(dLarge*((double)rgb1.rgbGreen) +
1208
												dSmallAmt)));
1208
												dSmallAmt)));
1209
								rgbDest.rgbRed = (BYTE)max(0,min(255,(int)(dLarge*((double)rgb1.rgbRed) +
1209
								rgbDest.rgbRed = (BYTE)__max(0,__min(255,(int)(dLarge*((double)rgb1.rgbRed) +
1210
												dSmallAmt)));
1210
												dSmallAmt)));
1211
							}
1211
							}
1212
							else
1212
							else
Lines 1274-1282 bool CxImage::ShiftRGB(long r, long g, long b) Link Here
1274
#endif //CXIMAGE_SUPPORT_SELECTION
1274
#endif //CXIMAGE_SUPPORT_SELECTION
1275
				{
1275
				{
1276
					color = BlindGetPixelColor(x,y);
1276
					color = BlindGetPixelColor(x,y);
1277
					color.rgbRed = (BYTE)max(0,min(255,(int)(color.rgbRed + r)));
1277
					color.rgbRed = (BYTE)__max(0,__min(255,(int)(color.rgbRed + r)));
1278
					color.rgbGreen = (BYTE)max(0,min(255,(int)(color.rgbGreen + g)));
1278
					color.rgbGreen = (BYTE)__max(0,__min(255,(int)(color.rgbGreen + g)));
1279
					color.rgbBlue = (BYTE)max(0,min(255,(int)(color.rgbBlue + b)));
1279
					color.rgbBlue = (BYTE)__max(0,__min(255,(int)(color.rgbBlue + b)));
1280
					BlindSetPixelColor(x,y,color);
1280
					BlindSetPixelColor(x,y,color);
1281
				}
1281
				}
1282
			}
1282
			}
Lines 1284-1292 bool CxImage::ShiftRGB(long r, long g, long b) Link Here
1284
	} else {
1284
	} else {
1285
		for(DWORD j=0; j<head.biClrUsed; j++){
1285
		for(DWORD j=0; j<head.biClrUsed; j++){
1286
			color = GetPaletteColor((BYTE)j);
1286
			color = GetPaletteColor((BYTE)j);
1287
			color.rgbRed = (BYTE)max(0,min(255,(int)(color.rgbRed + r)));
1287
			color.rgbRed = (BYTE)__max(0,__min(255,(int)(color.rgbRed + r)));
1288
			color.rgbGreen = (BYTE)max(0,min(255,(int)(color.rgbGreen + g)));
1288
			color.rgbGreen = (BYTE)__max(0,__min(255,(int)(color.rgbGreen + g)));
1289
			color.rgbBlue = (BYTE)max(0,min(255,(int)(color.rgbBlue + b)));
1289
			color.rgbBlue = (BYTE)__max(0,__min(255,(int)(color.rgbBlue + b)));
1290
			SetPaletteColor((BYTE)j,color);
1290
			SetPaletteColor((BYTE)j,color);
1291
		}
1291
		}
1292
	}
1292
	}
Lines 1310-1316 bool CxImage::Gamma(float gamma) Link Here
1310
1310
1311
	BYTE cTable[256]; //<nipper>
1311
	BYTE cTable[256]; //<nipper>
1312
	for (int i=0;i<256;i++)	{
1312
	for (int i=0;i<256;i++)	{
1313
		cTable[i] = (BYTE)max(0,min(255,(int)( pow((double)i, dinvgamma) / dMax)));
1313
		cTable[i] = (BYTE)__max(0,__min(255,(int)( pow((double)i, dinvgamma) / dMax)));
1314
	}
1314
	}
1315
1315
1316
	return Lut(cTable);
1316
	return Lut(cTable);
Lines 1337-1357 bool CxImage::GammaRGB(float gammaR, float gammaG, float gammaB) Link Here
1337
	dMax = pow(255.0, dinvgamma) / 255.0;
1337
	dMax = pow(255.0, dinvgamma) / 255.0;
1338
	BYTE cTableR[256];
1338
	BYTE cTableR[256];
1339
	for (i=0;i<256;i++)	{
1339
	for (i=0;i<256;i++)	{
1340
		cTableR[i] = (BYTE)max(0,min(255,(int)( pow((double)i, dinvgamma) / dMax)));
1340
		cTableR[i] = (BYTE)__max(0,__min(255,(int)( pow((double)i, dinvgamma) / dMax)));
1341
	}
1341
	}
1342
1342
1343
	dinvgamma = 1/gammaG;
1343
	dinvgamma = 1/gammaG;
1344
	dMax = pow(255.0, dinvgamma) / 255.0;
1344
	dMax = pow(255.0, dinvgamma) / 255.0;
1345
	BYTE cTableG[256];
1345
	BYTE cTableG[256];
1346
	for (i=0;i<256;i++)	{
1346
	for (i=0;i<256;i++)	{
1347
		cTableG[i] = (BYTE)max(0,min(255,(int)( pow((double)i, dinvgamma) / dMax)));
1347
		cTableG[i] = (BYTE)__max(0,__min(255,(int)( pow((double)i, dinvgamma) / dMax)));
1348
	}
1348
	}
1349
1349
1350
	dinvgamma = 1/gammaB;
1350
	dinvgamma = 1/gammaB;
1351
	dMax = pow(255.0, dinvgamma) / 255.0;
1351
	dMax = pow(255.0, dinvgamma) / 255.0;
1352
	BYTE cTableB[256];
1352
	BYTE cTableB[256];
1353
	for (i=0;i<256;i++)	{
1353
	for (i=0;i<256;i++)	{
1354
		cTableB[i] = (BYTE)max(0,min(255,(int)( pow((double)i, dinvgamma) / dMax)));
1354
		cTableB[i] = (BYTE)__max(0,__min(255,(int)( pow((double)i, dinvgamma) / dMax)));
1355
	}
1355
	}
1356
1356
1357
	return Lut(cTableR, cTableG, cTableB);
1357
	return Lut(cTableR, cTableG, cTableB);
Lines 1442-1452 bool CxImage::Noise(long level) Link Here
1442
			{
1442
			{
1443
				color = BlindGetPixelColor(x,y);
1443
				color = BlindGetPixelColor(x,y);
1444
				n=(long)((rand()/(float)RAND_MAX - 0.5)*level);
1444
				n=(long)((rand()/(float)RAND_MAX - 0.5)*level);
1445
				color.rgbRed = (BYTE)max(0,min(255,(int)(color.rgbRed + n)));
1445
				color.rgbRed = (BYTE)__max(0,__min(255,(int)(color.rgbRed + n)));
1446
				n=(long)((rand()/(float)RAND_MAX - 0.5)*level);
1446
				n=(long)((rand()/(float)RAND_MAX - 0.5)*level);
1447
				color.rgbGreen = (BYTE)max(0,min(255,(int)(color.rgbGreen + n)));
1447
				color.rgbGreen = (BYTE)__max(0,__min(255,(int)(color.rgbGreen + n)));
1448
				n=(long)((rand()/(float)RAND_MAX - 0.5)*level);
1448
				n=(long)((rand()/(float)RAND_MAX - 0.5)*level);
1449
				color.rgbBlue = (BYTE)max(0,min(255,(int)(color.rgbBlue + n)));
1449
				color.rgbBlue = (BYTE)__max(0,__min(255,(int)(color.rgbBlue + n)));
1450
				BlindSetPixelColor(x,y,color);
1450
				BlindSetPixelColor(x,y,color);
1451
			}
1451
			}
1452
		}
1452
		}
Lines 1561-1568 bool CxImage::FFT2(CxImage* srcReal, CxImage* srcImag, CxImage* dstReal, CxImage Link Here
1561
1561
1562
	//DFT buffers
1562
	//DFT buffers
1563
	double *real2,*imag2;
1563
	double *real2,*imag2;
1564
	real2 = (double*)malloc(max(w,h) * sizeof(double));
1564
	real2 = (double*)malloc(__max(w,h) * sizeof(double));
1565
	imag2 = (double*)malloc(max(w,h) * sizeof(double));
1565
	imag2 = (double*)malloc(__max(w,h) * sizeof(double));
1566
1566
1567
	/* Transform the rows */
1567
	/* Transform the rows */
1568
	real = (double *)malloc(w * sizeof(double));
1568
	real = (double *)malloc(w * sizeof(double));
Lines 1617-1623 bool CxImage::FFT2(CxImage* srcReal, CxImage* srcImag, CxImage* dstReal, CxImage Link Here
1617
1617
1618
	/* converting from double to byte, there is a HUGE loss in the dynamics
1618
	/* converting from double to byte, there is a HUGE loss in the dynamics
1619
	  "nn" tries to keep an acceptable SNR, but 8bit=48dB: don't ask more */
1619
	  "nn" tries to keep an acceptable SNR, but 8bit=48dB: don't ask more */
1620
	double nn=pow((double)2,(double)log((double)max(w,h))/(double)log((double)2)-4);
1620
	double nn=pow((double)2,(double)log((double)__max(w,h))/(double)log((double)2)-4);
1621
	//reversed gain for reversed transform
1621
	//reversed gain for reversed transform
1622
	if (direction==-1) nn=1/nn;
1622
	if (direction==-1) nn=1/nn;
1623
	//bMagnitude : just to see it on the screen
1623
	//bMagnitude : just to see it on the screen
Lines 1626-1640 bool CxImage::FFT2(CxImage* srcReal, CxImage* srcImag, CxImage* dstReal, CxImage Link Here
1626
	for (j=0;j<h;j++) {
1626
	for (j=0;j<h;j++) {
1627
		for (k=0;k<w;k++) {
1627
		for (k=0;k<w;k++) {
1628
			if (bMagnitude){
1628
			if (bMagnitude){
1629
				tmpReal->SetPixelIndex(k,j,(BYTE)max(0,min(255,(nn*(3+log(_cabs(grid[k][j])))))));
1629
				tmpReal->SetPixelIndex(k,j,(BYTE)__max(0,__min(255,(nn*(3+log(_cabs(grid[k][j])))))));
1630
				if (grid[k][j].x==0){
1630
				if (grid[k][j].x==0){
1631
					tmpImag->SetPixelIndex(k,j,(BYTE)max(0,min(255,(128+(atan(grid[k][j].y/0.0000000001)*nn)))));
1631
					tmpImag->SetPixelIndex(k,j,(BYTE)__max(0,__min(255,(128+(atan(grid[k][j].y/0.0000000001)*nn)))));
1632
				} else {
1632
				} else {
1633
					tmpImag->SetPixelIndex(k,j,(BYTE)max(0,min(255,(128+(atan(grid[k][j].y/grid[k][j].x)*nn)))));
1633
					tmpImag->SetPixelIndex(k,j,(BYTE)__max(0,__min(255,(128+(atan(grid[k][j].y/grid[k][j].x)*nn)))));
1634
				}
1634
				}
1635
			} else {
1635
			} else {
1636
				tmpReal->SetPixelIndex(k,j,(BYTE)max(0,min(255,(128 + grid[k][j].x*nn))));
1636
				tmpReal->SetPixelIndex(k,j,(BYTE)__max(0,__min(255,(128 + grid[k][j].x*nn))));
1637
				tmpImag->SetPixelIndex(k,j,(BYTE)max(0,min(255,(128 + grid[k][j].y*nn))));
1637
				tmpImag->SetPixelIndex(k,j,(BYTE)__max(0,__min(255,(128 + grid[k][j].y*nn))));
1638
			}
1638
			}
1639
		}
1639
		}
1640
	}
1640
	}
Lines 1922-1928 bool CxImage::RepairChannel(CxImage *ch, float radius) Link Here
1922
1922
1923
			correction = ((1.0+iy*iy)*ixx - ix*iy*ixy + (1.0+ix*ix)*iyy)/(1.0+ix*ix+iy*iy);
1923
			correction = ((1.0+iy*iy)*ixx - ix*iy*ixy + (1.0+ix*ix)*iyy)/(1.0+ix*ix+iy*iy);
1924
1924
1925
			tmp.BlindSetPixelIndex(x,y,(BYTE)min(255,max(0,(xy0 + radius * correction + 0.5))));
1925
			tmp.BlindSetPixelIndex(x,y,(BYTE)__min(255,__max(0,(xy0 + radius * correction + 0.5))));
1926
		}
1926
		}
1927
	}
1927
	}
1928
1928
Lines 1943-1949 bool CxImage::RepairChannel(CxImage *ch, float radius) Link Here
1943
1943
1944
			correction = ((1.0+iy*iy)*ixx - ix*iy*ixy + (1.0+ix*ix)*iyy)/(1.0+ix*ix+iy*iy);
1944
			correction = ((1.0+iy*iy)*ixx - ix*iy*ixy + (1.0+ix*ix)*iyy)/(1.0+ix*ix+iy*iy);
1945
1945
1946
			tmp.BlindSetPixelIndex(x,y,(BYTE)min(255,max(0,(xy0 + radius * correction + 0.5))));
1946
			tmp.BlindSetPixelIndex(x,y,(BYTE)__min(255,__max(0,(xy0 + radius * correction + 0.5))));
1947
		}
1947
		}
1948
	}
1948
	}
1949
	for (x=0;x<=w;x+=w){
1949
	for (x=0;x<=w;x+=w){
Lines 1963-1969 bool CxImage::RepairChannel(CxImage *ch, float radius) Link Here
1963
1963
1964
			correction = ((1.0+iy*iy)*ixx - ix*iy*ixy + (1.0+ix*ix)*iyy)/(1.0+ix*ix+iy*iy);
1964
			correction = ((1.0+iy*iy)*ixx - ix*iy*ixy + (1.0+ix*ix)*iyy)/(1.0+ix*ix+iy*iy);
1965
1965
1966
			tmp.BlindSetPixelIndex(x,y,(BYTE)min(255,max(0,(xy0 + radius * correction + 0.5))));
1966
			tmp.BlindSetPixelIndex(x,y,(BYTE)__min(255,__max(0,(xy0 + radius * correction + 0.5))));
1967
		}
1967
		}
1968
	}
1968
	}
1969
1969
Lines 2621-2628 bool CxImage::SelectiveBlur(float radius, BYTE threshold, CxImage* iDst) Link Here
2621
	}
2621
	}
2622
2622
2623
	//build the difference mask
2623
	//build the difference mask
2624
	BYTE thresh_dw = (BYTE)max( 0 ,(int)(128 - threshold));
2624
	BYTE thresh_dw = (BYTE)__max( 0 ,(int)(128 - threshold));
2625
	BYTE thresh_up = (BYTE)min(255,(int)(128 + threshold));
2625
	BYTE thresh_up = (BYTE)__min(255,(int)(128 + threshold));
2626
	long kernel[]={-100,-100,-100,-100,801,-100,-100,-100,-100};
2626
	long kernel[]={-100,-100,-100,-100,801,-100,-100,-100,-100};
2627
	if (!Tmp.Filter(kernel,3,800,128)){
2627
	if (!Tmp.Filter(kernel,3,800,128)){
2628
		delete [] pPalette;
2628
		delete [] pPalette;
Lines 2685-2691 bool CxImage::SelectiveBlur(float radius, BYTE threshold, CxImage* iDst) Link Here
2685
/**
2685
/**
2686
 * sharpen the image by subtracting a blurred copy from the original image.
2686
 * sharpen the image by subtracting a blurred copy from the original image.
2687
 * \param radius: width in pixels of the blurring effect. Range: >0; default = 5.
2687
 * \param radius: width in pixels of the blurring effect. Range: >0; default = 5.
2688
 * \param amount: strength of the filter. Range: 0.0 (none) to 1.0 (max); default = 0.5
2688
 * \param amount: strength of the filter. Range: 0.0 (none) to 1.0 (__max); default = 0.5
2689
 * \param threshold: difference, between blurred and original pixel, to trigger the filter
2689
 * \param threshold: difference, between blurred and original pixel, to trigger the filter
2690
 *                   Range: 0 (always triggered) to 255 (never triggered); default = 0.
2690
 *                   Range: 0 (always triggered) to 255 (never triggered); default = 0.
2691
 * \return true if everything is ok
2691
 * \return true if everything is ok
Lines 2755-2761 bool CxImage::UnsharpMask(float radius /*= 5.0*/, float amount /*= 0.5*/, int th Link Here
2755
					if (abs(diff) < threshold){
2755
					if (abs(diff) < threshold){
2756
						dest_row[z] = cur_row[z];
2756
						dest_row[z] = cur_row[z];
2757
					} else {
2757
					} else {
2758
						dest_row[z] = (BYTE)min(255, max(0,(int)(cur_row[z] + amount * diff)));
2758
						dest_row[z] = (BYTE)__min(255, __max(0,(int)(cur_row[z] + amount * diff)));
2759
					}
2759
					}
2760
				}
2760
				}
2761
			}
2761
			}
Lines 2952-2958 bool CxImage::RedEyeRemove(float strength) Link Here
2952
				float a = 1.0f-5.0f*((float)((x-0.5f*(xmax+xmin))*(x-0.5f*(xmax+xmin))+(y-0.5f*(ymax+ymin))*(y-0.5f*(ymax+ymin))))/((float)((xmax-xmin)*(ymax-ymin)));
2952
				float a = 1.0f-5.0f*((float)((x-0.5f*(xmax+xmin))*(x-0.5f*(xmax+xmin))+(y-0.5f*(ymax+ymin))*(y-0.5f*(ymax+ymin))))/((float)((xmax-xmin)*(ymax-ymin)));
2953
				if (a<0) a=0;
2953
				if (a<0) a=0;
2954
				color = BlindGetPixelColor(x,y);
2954
				color = BlindGetPixelColor(x,y);
2955
				color.rgbRed = (BYTE)(a*min(color.rgbGreen,color.rgbBlue)+(1.0f-a)*color.rgbRed);
2955
				color.rgbRed = (BYTE)(a*__min(color.rgbGreen,color.rgbBlue)+(1.0f-a)*color.rgbRed);
2956
				BlindSetPixelColor(x,y,color);
2956
				BlindSetPixelColor(x,y,color);
2957
			}
2957
			}
2958
		}
2958
		}
Lines 2990-2996 bool CxImage::Saturate(const long saturation, const long colorspace) Link Here
2990
	case 1:
2990
	case 1:
2991
		{
2991
		{
2992
			for (int i=0;i<256;i++)	{
2992
			for (int i=0;i<256;i++)	{
2993
				cTable[i] = (BYTE)max(0,min(255,(int)(i + saturation)));
2993
				cTable[i] = (BYTE)__max(0,__min(255,(int)(i + saturation)));
2994
			}
2994
			}
2995
			for(long y=ymin; y<ymax; y++){
2995
			for(long y=ymin; y<ymax; y++){
2996
				info.nProgress = (long)(100*(y-ymin)/(ymax-ymin));
2996
				info.nProgress = (long)(100*(y-ymin)/(ymax-ymin));
Lines 3012-3018 bool CxImage::Saturate(const long saturation, const long colorspace) Link Here
3012
	case 2:
3012
	case 2:
3013
		{
3013
		{
3014
			for (int i=0;i<256;i++)	{
3014
			for (int i=0;i<256;i++)	{
3015
				cTable[i] = (BYTE)max(0,min(255,(int)((i-128)*(100 + saturation)/100.0f + 128.5f)));
3015
				cTable[i] = (BYTE)__max(0,__min(255,(int)((i-128)*(100 + saturation)/100.0f + 128.5f)));
3016
			}
3016
			}
3017
			for(long y=ymin; y<ymax; y++){
3017
			for(long y=ymin; y<ymax; y++){
3018
				info.nProgress = (long)(100*(y-ymin)/(ymax-ymin));
3018
				info.nProgress = (long)(100*(y-ymin)/(ymax-ymin));
Lines 3242-3251 int CxImage::OptimalThreshold(long method, RECT * pBox, CxImage* pContrastMask) Link Here
3242
3242
3243
	long xmin,xmax,ymin,ymax;
3243
	long xmin,xmax,ymin,ymax;
3244
	if (pBox){
3244
	if (pBox){
3245
		xmin = max(pBox->left,0);
3245
		xmin = __max(pBox->left,0);
3246
		xmax = min(pBox->right,head.biWidth);
3246
		xmax = __min(pBox->right,head.biWidth);
3247
		ymin = max(pBox->bottom,0);
3247
		ymin = __max(pBox->bottom,0);
3248
		ymax = min(pBox->top,head.biHeight);
3248
		ymax = __min(pBox->top,head.biHeight);
3249
	} else {
3249
	} else {
3250
		xmin = ymin = 0;
3250
		xmin = ymin = 0;
3251
		xmax = head.biWidth; ymax=head.biHeight;
3251
		xmax = head.biWidth; ymax=head.biHeight;
Lines 3463-3469 bool CxImage::AdaptiveThreshold(long method, long nBoxSize, CxImage* pContrastMa Link Here
3463
			r.top = r.bottom + nBoxSize;
3463
			r.top = r.bottom + nBoxSize;
3464
			int threshold = OptimalThreshold(method, &r, pContrastMask);
3464
			int threshold = OptimalThreshold(method, &r, pContrastMask);
3465
			if (threshold <0) return false;
3465
			if (threshold <0) return false;
3466
			mask.SetPixelIndex(x,y,(BYTE)max(0,min(255,nBias+((1.0f-fGlobalLocalBalance)*threshold + fGlobalLocalBalance*globalthreshold))));
3466
			mask.SetPixelIndex(x,y,(BYTE)__max(0,__min(255,nBias+((1.0f-fGlobalLocalBalance)*threshold + fGlobalLocalBalance*globalthreshold))));
3467
		}
3467
		}
3468
	}
3468
	}
3469
3469
Lines 3538-3545 bool CxImage::FloodFill(const long xStart, const long yStart, const RGBQUAD cFil Link Here
3538
	if (IsIndexed()){ //--- Generic indexed image, no tolerance OR Grayscale image with tolerance
3538
	if (IsIndexed()){ //--- Generic indexed image, no tolerance OR Grayscale image with tolerance
3539
		BYTE idxRef = GetPixelIndex(xStart,yStart);
3539
		BYTE idxRef = GetPixelIndex(xStart,yStart);
3540
		BYTE idxFill = GetNearestIndex(cFillColor);
3540
		BYTE idxFill = GetNearestIndex(cFillColor);
3541
		BYTE idxMin = (BYTE)min(255, max(0,(int)(idxRef - nTolerance)));
3541
		BYTE idxMin = (BYTE)__min(255, max(0,(int)(idxRef - nTolerance)));
3542
		BYTE idxMax = (BYTE)min(255, max(0,(int)(idxRef + nTolerance)));
3542
		BYTE idxMax = (BYTE)__min(255, max(0,(int)(idxRef + nTolerance)));
3543
3543
3544
		while(!q.empty())
3544
		while(!q.empty())
3545
		{
3545
		{
Lines 3575-3586 bool CxImage::FloodFill(const long xStart, const long yStart, const RGBQUAD cFil Link Here
3575
	} else { //--- RGB image
3575
	} else { //--- RGB image
3576
		RGBQUAD cRef = GetPixelColor(xStart,yStart);
3576
		RGBQUAD cRef = GetPixelColor(xStart,yStart);
3577
		RGBQUAD cRefMin, cRefMax;
3577
		RGBQUAD cRefMin, cRefMax;
3578
		cRefMin.rgbRed   = (BYTE)min(255, max(0,(int)(cRef.rgbRed   - nTolerance)));
3578
		cRefMin.rgbRed   = (BYTE)__min(255, max(0,(int)(cRef.rgbRed   - nTolerance)));
3579
		cRefMin.rgbGreen = (BYTE)min(255, max(0,(int)(cRef.rgbGreen - nTolerance)));
3579
		cRefMin.rgbGreen = (BYTE)__min(255, max(0,(int)(cRef.rgbGreen - nTolerance)));
3580
		cRefMin.rgbBlue  = (BYTE)min(255, max(0,(int)(cRef.rgbBlue  - nTolerance)));
3580
		cRefMin.rgbBlue  = (BYTE)__min(255, max(0,(int)(cRef.rgbBlue  - nTolerance)));
3581
		cRefMax.rgbRed   = (BYTE)min(255, max(0,(int)(cRef.rgbRed   + nTolerance)));
3581
		cRefMax.rgbRed   = (BYTE)__min(255, max(0,(int)(cRef.rgbRed   + nTolerance)));
3582
		cRefMax.rgbGreen = (BYTE)min(255, max(0,(int)(cRef.rgbGreen + nTolerance)));
3582
		cRefMax.rgbGreen = (BYTE)__min(255, max(0,(int)(cRef.rgbGreen + nTolerance)));
3583
		cRefMax.rgbBlue  = (BYTE)min(255, max(0,(int)(cRef.rgbBlue  + nTolerance)));
3583
		cRefMax.rgbBlue  = (BYTE)__min(255, max(0,(int)(cRef.rgbBlue  + nTolerance)));
3584
3584
3585
		while(!q.empty())
3585
		while(!q.empty())
3586
		{
3586
		{
(-)a/lib/cximage-6.0/CxImage/ximaiter.h (-2 / +2 lines)
Lines 140-146 inline void CImageIterator::SetY(int y) Link Here
140
inline void CImageIterator::SetRow(BYTE *buf, int n)
140
inline void CImageIterator::SetRow(BYTE *buf, int n)
141
{
141
{
142
	if (n<0) n = (int)ima->GetEffWidth();
142
	if (n<0) n = (int)ima->GetEffWidth();
143
	else n = min(n,(int)ima->GetEffWidth());
143
	else n = __min(n,(int)ima->GetEffWidth());
144
144
145
	if ((IterImage!=NULL)&&(buf!=NULL)&&(n>0)) memcpy(IterImage,buf,n);
145
	if ((IterImage!=NULL)&&(buf!=NULL)&&(n>0)) memcpy(IterImage,buf,n);
146
}
146
}
Lines 148-154 inline void CImageIterator::SetRow(BYTE *buf, int n) Link Here
148
inline void CImageIterator::GetRow(BYTE *buf, int n)
148
inline void CImageIterator::GetRow(BYTE *buf, int n)
149
{
149
{
150
	if ((IterImage!=NULL)&&(buf!=NULL)&&(n>0))
150
	if ((IterImage!=NULL)&&(buf!=NULL)&&(n>0))
151
		memcpy(buf,IterImage,min(n,(int)ima->GetEffWidth()));
151
		memcpy(buf,IterImage,__min(n,(int)ima->GetEffWidth()));
152
}
152
}
153
/////////////////////////////////////////////////////////////////////
153
/////////////////////////////////////////////////////////////////////
154
inline BYTE* CImageIterator::GetRow()
154
inline BYTE* CImageIterator::GetRow()
(-)a/lib/cximage-6.0/CxImage/ximapng.cpp (-6 / +6 lines)
Lines 206-214 bool CxImagePNG::Decode(CxFile *hFile) Link Here
206
	} else SetGrayPalette(); //<DP> needed for grayscale PNGs
206
	} else SetGrayPalette(); //<DP> needed for grayscale PNGs
207
	
207
	
208
#ifdef USE_NEW_LIBPNG_API
208
#ifdef USE_NEW_LIBPNG_API
209
	int nshift = max(0,(_bit_depth>>3)-1)<<3;
209
	int nshift = __max(0,(_bit_depth>>3)-1)<<3;
210
#else
210
#else
211
	int nshift = max(0,(info_ptr->bit_depth>>3)-1)<<3;
211
	int nshift = __max(0,(info_ptr->bit_depth>>3)-1)<<3;
212
#endif
212
#endif
213
213
214
#ifdef USE_NEW_LIBPNG_API
214
#ifdef USE_NEW_LIBPNG_API
Lines 255-264 bool CxImagePNG::Decode(CxFile *hFile) Link Here
255
			if (pal){
255
			if (pal){
256
				DWORD ip;
256
				DWORD ip;
257
#ifdef USE_NEW_LIBPNG_API
257
#ifdef USE_NEW_LIBPNG_API
258
				for (ip=0;ip<min(head.biClrUsed,(unsigned long)_num_trans);ip++)
258
				for (ip=0;ip<__min(head.biClrUsed,(unsigned long)_num_trans);ip++)
259
					pal[ip].rgbReserved=_trans_alpha[ip];
259
					pal[ip].rgbReserved=_trans_alpha[ip];
260
#else
260
#else
261
				for (ip=0;ip<min(head.biClrUsed,(unsigned long)info_ptr->num_trans);ip++)
261
				for (ip=0;ip<__min(head.biClrUsed,(unsigned long)info_ptr->num_trans);ip++)
262
#if PNG_LIBPNG_VER > 10399
262
#if PNG_LIBPNG_VER > 10399
263
					pal[ip].rgbReserved=info_ptr->trans_alpha[ip];
263
					pal[ip].rgbReserved=info_ptr->trans_alpha[ip];
264
#else
264
#else
Lines 737-745 bool CxImagePNG::Encode(CxFile *hFile) Link Here
737
#endif // CXIMAGE_SUPPORT_ALPHA	// <vho>
737
#endif // CXIMAGE_SUPPORT_ALPHA	// <vho>
738
738
739
#ifdef USE_NEW_LIBPNG_API
739
#ifdef USE_NEW_LIBPNG_API
740
	int row_size = max(info.dwEffWidth, (_width * _channels * _bit_depth / 8));
740
	int row_size = __max(info.dwEffWidth, (_width * _channels * _bit_depth / 8));
741
#else
741
#else
742
	int row_size = max(info.dwEffWidth, info_ptr->width*info_ptr->channels*(info_ptr->bit_depth/8));
742
	int row_size = __max(info.dwEffWidth, info_ptr->width*info_ptr->channels*(info_ptr->bit_depth/8));
743
	info_ptr->rowbytes = row_size;
743
	info_ptr->rowbytes = row_size;
744
#endif
744
#endif
745
	BYTE *row_pointers = new BYTE[row_size];
745
	BYTE *row_pointers = new BYTE[row_size];
(-)a/lib/cximage-6.0/CxImage/ximatif.cpp (-4 / +3 lines)
Lines 470-478 bool CxImageTIF::Decode(CxFile * hFile) Link Here
470
						if ( cb > 0.00304 ) cb = 1.055 * pow(cb,0.41667) - 0.055;
470
						if ( cb > 0.00304 ) cb = 1.055 * pow(cb,0.41667) - 0.055;
471
							else            cb = 12.92 * cb;
471
							else            cb = 12.92 * cb;
472
472
473
						c.rgbRed  =(BYTE)max(0,min(255,(int)(cr*255)));
473
						c.rgbRed  =(BYTE)__max(0,__min(255,(int)(cr*255)));
474
						c.rgbGreen=(BYTE)max(0,min(255,(int)(cg*255)));
474
						c.rgbGreen=(BYTE)__max(0,__min(255,(int)(cg*255)));
475
						c.rgbBlue =(BYTE)max(0,min(255,(int)(cb*255)));
475
						c.rgbBlue =(BYTE)__max(0,__min(255,(int)(cb*255)));
476
476
477
						SetPixelColor(xi,yi,c);
477
						SetPixelColor(xi,yi,c);
478
#if CXIMAGE_SUPPORT_ALPHA
478
#if CXIMAGE_SUPPORT_ALPHA
479
- 

Return to bug 592446