版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、本文实例汇总了Delphi基本图像处理方法。分享给大家供大家参考。具体分析如下: /浮雕 procedure Emboss(SrcBmp,DestBmp:TBitmap;AzimuthChange:integer;overload; var i, j, Gray, Azimuthvalue, R, G, B: integer; SrcRGB, SrcRGB1, SrcRGB2, DestRGB: pRGBTriple; begin for i := 0 to SrcBmp.Height - 1 do begin SrcRGB := SrcBmp.ScanLinei; DestRGB := De
2、stBmp.ScanLinei; if (AzimuthChange >= -180 and (AzimuthChange < -135 then begin if i > 0 then SrcRGB1 := SrcBmp.ScanLinei-1 else SrcRGB1 := SrcRGB; Inc(SrcRGB1; SrcRGB2 := SrcRGB; Inc(SrcRGB2; end else if (AzimuthChange >= -135 and (AzimuthChange < -90 then begin if i > 0 then SrcR
3、GB1 := SrcBmp.ScanLinei-1 else SrcRGB1 := SrcRGB; SrcRGB2 := SrcRGB1; Inc(SrcRGB2; end else if (AzimuthChange >= -90 and (AzimuthChange < -45 then begin if i > 0 then SrcRGB1 := SrcBmp.ScanLinei-1 else SrcRGB1 := SrcRGB; SrcRGB2 := SrcRGB1; end else if (AzimuthChange >= -45 and (AzimuthC
4、hange < 0 then begin SrcRGB1 := SrcRGB; if i > 0 then SrcRGB2 := SrcBmp.ScanLinei-1 else SrcRGB2 := SrcRGB; end else if (AzimuthChange >= 0 and (AzimuthChange < 45 then begin SrcRGB2 := SrcRGB; if (i < SrcBmp.Height - 1 then SrcRGB1 := SrcBmp.ScanLinei+1 else SrcRGB1 := SrcRGB; end el
5、se if (AzimuthChange >= 45 and (AzimuthChange < 90 then begin if (i < SrcBmp.Height - 1 then SrcRGB1 := SrcBmp.ScanLinei+1 else SrcRGB1 := SrcRGB; SrcRGB2 := SrcRGB1; end else if (AzimuthChange >= 90 and (AzimuthChange < 135 then begin if (i < SrcBmp.Height - 1 then SrcRGB1 := SrcB
6、mp.ScanLinei+1 else SrcRGB1 := SrcRGB; SrcRGB2 := SrcRGB1; Inc(SrcRGB1; end else if (AzimuthChange >= 135 and (AzimuthChange <= 180 then begin if (i < SrcBmp.Height - 1 then SrcRGB2 := SrcBmp.ScanLinei+1 else SrcRGB2 := SrcRGB; Inc(SrcRGB2; SrcRGB1 := SrcRGB; Inc(SrcRGB1; end; for j := 0 to
7、 SrcBmp.Width - 1 do begin if (AzimuthChange >= -180 and (AzimuthChange < -135 then begin Azimuthvalue := AzimuthChange + 180; R:=SrcRGB.rgbtRed-(SrcRGB1.rgbtRed*Azimuthvalue div 45-(SrcRGB2.rgbtRed*(45-Azimuthvalue div 45+78; G:=SrcRGB.rgbtGreen-(SrcRGB1.rgbtGreen*Azimuthvalue div 45-(SrcRGB2
8、.rgbtGreen*(45-Azimuthvalue div 45+78; B:=SrcRGB.rgbtBlue-(SrcRGB1.rgbtBlue*Azimuthvalue div 45-(SrcRGB2.rgbtBlue*(45-Azimuthvalue div 45+78; end else if (AzimuthChange >= -135 and (AzimuthChange < -90 then begin Azimuthvalue := AzimuthChange + 135; R:=SrcRGB.rgbtRed-(SrcRGB1.rgbtRed*Azimuthva
9、lue div 45-(SrcRGB2.rgbtRed*(45-Azimuthvalue div 45+78; G:=SrcRGB.rgbtGreen-(SrcRGB1.rgbtGreen*Azimuthvalue div 45-(SrcRGB2.rgbtGreen*(45-Azimuthvalue div 45+78; B:=SrcR GB.rgbtBlue-(SrcRGB1.rgbtBlue*Azimuthvalue div 45-(SrcRGB2.rgbtBlue*(45-Azimuthvalue div 45+78; end else if (AzimuthChange >= -
10、90 and (AzimuthChange < -45 then begin if j=1 then Inc(SrcRGB1,-1; Azimuthvalue := AzimuthChange + 90; R:=SrcRGB.rgbtRed-(SrcRGB1.rgbtRed*Azimuthvalue div 45-(SrcRGB2.rgbtRed*(45-Azimuthvalue div 45+78; G:=SrcRGB.rgbtGreen-(SrcRGB1.rgbtGreen*Azimuthvalue div 45-(SrcRGB2.rgbtGreen*(45-Azimuthvalue
11、 div 45+78; B:=SrcRGB.rgbtBlue-(SrcRGB1.rgbtBlue*Azimuthvalue div 45-(SrcRGB2.rgbtBlue*(45-Azimuthvalue div 45+78; end else if (AzimuthChange >= -45 and (AzimuthChange < 0 then begin if j=1 then begin Inc(SrcRGB1,-1; Inc(SrcRGB2,-1; end; Azimuthvalue := AzimuthChange + 45; R:=SrcRGB.rgbtRed-(S
12、rcRGB1.rgbtRed*Azimuthvalue div 45-(SrcRGB2.rgbtRed*(45-Azimuthvalue div 45+78; G:=SrcRGB.rgbtGreen-(SrcRGB1.rgbtGreen*Azimuthvalue div 45-(SrcRGB2.rgbtGreen*(45-Azimuthvalue div 45+78; B:=SrcRGB.rgbtBlue-(SrcRGB1.rgbtBlue*Azimuthvalue div 45-(SrcRGB2.rgbtBlue*(45-Azimuthvalue div 45+78; end else if
13、 (AzimuthChange >= 0 and (AzimuthChange < 45 then begin if j=1 then begin Inc(SrcRGB1,-1; Inc(SrcRGB2,-1; end; Azimuthvalue := AzimuthChange; R:=SrcRGB.rgbtRed-(SrcRGB1.rgbtRed*Azimuthvalue div 45-(SrcRGB2.rgbtRed*(45-Azimuthvalue div 45+78; G:=SrcRGB.rgbtGreen-(SrcRGB1.rgbtGreen*Azimuthvalue
14、div 45-(SrcRGB2.rgbtGreen*(45-Azimuthvalue div 45+78; B:=SrcRGB.rgbtBlue-(SrcRGB1.rgbtBlue*Azimuthvalue div 45-(SrcRGB2.rgbtBlue*(45-Azimuthvalue div 45+78; end else if (AzimuthChange >= 45 and (AzimuthChange < 90 then begin if j=1 then Inc(SrcRGB2,-1; Azimuthvalue := AzimuthChange - 45; R:=Sr
15、cRGB.rgbtRed-(SrcRGB1.rgbtRed*Azimuthvalue div 45-(SrcRGB2.rgbtRed*(45-Azimuthvalue div 45+78; G:=SrcRGB.rgbtGreen-(SrcRGB1.rgbtGreen*Azimuthvalue div 45-(SrcRGB2.rgbtGreen*(45-Azimuthvalue div 45+78; B:=SrcRGB.rgbtBlue-(SrcRGB1.rgbtBlue*Azimuthvalue div 45-(SrcRGB2.rgbtBlue*(45-Azimuthvalue div 45+
16、78; end else if (AzimuthChange >= 90 and (AzimuthChange < 135 then begin Azimuthvalue := AzimuthChange - 90; R:=SrcRGB.rgbtRed-(SrcRGB1.rgbtRed*Azimuthvalue div 45-(SrcRGB2.rgbtRed*(45-Azimuthvalue div 45+78; G:=SrcRGB.rgbtGreen-(SrcRGB1.rgbtGreen*Azimuthvalue div 45-(SrcRGB2.rgbtGreen*(45-Azi
17、muthvalue div 45+78; B:=SrcRGB.rgbtBlue-(SrcRGB1.rgbtBlue*Azimuthvalue div 45-(SrcRGB2.rgbtBlue*(45-Azimuthvalue div 45+78; end else if (AzimuthChange >= 135 and (AzimuthChange <= 180 then begin Azimuthvalue := AzimuthChange - 135; R:=SrcRGB.rgbtRed-(SrcRGB1.rgbtRed*Azimuthvalue div 45-(SrcRGB
18、2.rgbtRed*(45-Azimuthvalue div 45+78; G:=SrcRGB.rgbtGreen-(SrcRGB1.rgbtGreen*Azimuthvalue div 45-(SrcRGB2.rgbtGree n*(45-Azimuthvalue div 45+78; B:=SrcRGB.rgbtBlue-(SrcRGB1.rgbtBlue*Azimuthvalue div 45-(SrcRGB2.rgbtBlue*(45-Azimuthvalue div 45+78; end; R:=Min(R,255; R:=Max(R,0; G:=Min(G,255; G:=Max(
19、G,0; B:=Min(B,255; B:=Max(B,0; Gray := (R shr 2 + (R shr 4 + (G shr 1 + (G shr 4 + (B shr 3; DestRGB.rgbtRed:=Gray; DestRGB.rgbtGreen:=Gray; DestRGB.rgbtBlue:=Gray; if (j=-180 and (AzimuthChange<-135 or (AzimuthChange>=90 and (AzimuthChange<=180 then begin Inc(SrcRGB1; end; if (j=135 and (A
20、zimuthChange<180 or (AzimuthChange>=-180 and (AzimuthChange<=-90 then begin Inc(SrcRGB2; end; Inc(SrcRGB; Inc(DestRGB; end; end; end; procedure Emboss(Bmp:TBitmap;AzimuthChange:integer;ElevationChange:integer;WeightChange:integer;overload; var DestBmp:TBitmap; begin DestBmp:=TBitmap.Create;
21、 DestBmp.Assign(Bmp; Emboss(Bmp,DestBmp,AzimuthChange,ElevationChange,WeightChange; Bmp.Assign(DestBmp; end; /反色 procedure Negative(Bmp:TBitmap; var i, j: Integer; PRGB: pRGBTriple; begin Bmp.PixelFormat:=pf24Bit; for i := 0 to Bmp.Height - 1 do begin PRGB := Bmp.ScanLinei; for j := 0 to Bmp.Width -
22、 1 do begin PRGB.rgbtRed :=not PRGB.rgbtRed ; PRGB.rgbtGreen :=not PRGB.rgbtGreen; PRGB.rgbtBlue :=not PRGB.rgbtBlue; Inc(PRGB; end; end; end; /曝光 procedure Exposure(Bmp:TBitmap; var i, j: integer; PRGB: pRGBTriple; begin Bmp.PixelFormat:=pf24Bit; for i := 0 to Bmp.Height - 1 do begin PRGB := Bmp.Sc
23、anLinei; for j := 0 to Bmp.Width - 1 do begin if PRGB.rgbtRed<128 then PRGB.rgbtRed :=not PRGB.rgbtRed ; if PRGB.rgbtGreen<128 then PRGB.rgbtGreen :=not PRGB.rgbtGreen; if PRGB.rgbtBlue<128 then PRGB.rgbtBlue :=not PRGB.rgbtBlue; Inc(PRGB; end; end; end; /模糊 procedure Blur(SrcBmp:TBitmap; v
24、ar i, j:Integer; SrcRGB:pRGBTriple; SrcNextRGB:pRGBTriple; SrcPreRGB:pRGBTriple; Value:Integer; procedure IncRGB; begin Inc(SrcPreRGB; Inc(SrcRGB; Inc(SrcNextRGB; end; procedure DecRGB; begin Inc(SrcPreRGB,-1; Inc(SrcRGB,-1; Inc(SrcNextRGB,-1; end; begin SrcBmp.PixelFormat:=pf24Bit; for i := 0 to Sr
25、cBmp.Height - 1 do begin if i > 0 then SrcPreRGB:=SrcBmp.ScanLinei-1 else SrcPreRGB := SrcBmp.ScanLinei; SrcRGB := SrcBmp.ScanLinei; if i < SrcBmp.Height - 1 then SrcNextRGB:=SrcBmp.ScanLinei+1 else SrcNextRGB:=SrcBmp.ScanLinei; for j := 0 to SrcBmp.Width - 1 do begin if j > 0 then DecRGB;
26、Value:=SrcPreRGB.rgbtRed+SrcRGB.rgbtRed+SrcNextRGB.rgbtRed; if j > 0 then IncRGB; Value:=Value+SrcPreRGB.rgbtRed+SrcRGB.rgbtRed+SrcNextRGB.rgbtRed; if j < SrcBmp.Width - 1 then IncRGB; Value:=(Value+SrcPreRGB.rgbtRed+SrcRGB.rgbtRed+SrcNextRGB.rgbtRed div 9; DecRGB; SrcRGB.rgbtRed:=value; if j
27、> 0 then DecRGB; Value:=SrcPreRGB.rgbtGreen+SrcRGB.rgbtGreen+SrcNextRGB.rgbtGreen; if j > 0 then IncRGB; Value:=Value+SrcPreRGB.rgbtGreen+SrcRGB.rgbtGreen+SrcNextRGB.rgbtGreen; if j < SrcBmp.Width - 1 then IncRGB; Value:=(Value+SrcPreRGB.rgbtGreen+SrcRGB.rgbtGreen+SrcNextRGB.rgbtGreen div 9
28、; DecRGB; SrcRGB.rgbtGreen:=value; if j > 0 then DecRGB; Value:=SrcPreRGB.rgbtBlue+SrcRGB.rgbtBlue+SrcNextRGB.rgbtBlue; if j > 0 then IncRGB; Value:=Value+SrcPreRGB.rgbtBlue+SrcRGB.rgbtBlue+SrcNextRGB.rgbtBlue; if j < SrcBmp.Width - 1 then IncRGB; Value:=(Value+SrcPreRGB.rgbtBlue+SrcRGB.rgb
29、tBlue+SrcNextRGB.rgbtBlue div 9; DecRGB; SrcRGB.rgbtBlue:=value; IncRGB; end; end; end; /锐化 procedure Sharpen(SrcBmp:TBitmap; var i, j: integer; SrcRGB: pRGBTriple; SrcPreRGB: pRGBTriple; Value: integer; begin SrcBmp.PixelFormat:=pf24Bit; for i := 0 to SrcBmp.Height - 1 do begin SrcRGB := SrcBmp.Sca
30、nLinei; if i > 0 then SrcPreRGB:=SrcBmp.ScanLinei-1 else SrcPreRGB:=SrcBmp.ScanLinei; for j := 0 to SrcBmp.Width - 1 do begin if j = 1 then Dec(SrcPreRGB; Value:=SrcRGB.rgbtRed+(SrcRGB.rgbtRed-SrcPreRGB.rgbtRed div 2; Value:=Max(0,Value; Value:=Min(255,Value; SrcRGB.rgbtRed:=value; Value:=SrcRGB.
31、rgbtGreen+(SrcRGB.rgbtGreen-SrcPreRGB.rgbtGreen div 2; Value:=Max(0,Value; Value:=Min(255,Value; SrcRGB.rgbtGreen:=value; Value:=SrcRGB.rgbtBlue+(SrcRGB.rgbtBlue-SrcPreRGB.rgbtBlue div 2; Value:=Max(0,Value; Value:=Min(255,Value; SrcRGB.rgbtBlue:=value; Inc(SrcRGB; Inc(SrcPreRGB; end; end; end; 图像的旋
32、转和翻转 以下代码用ScanLine配合指针移动实现,用于24位色! /旋转90度 procedure Rotate90(const Bitmap:TBitmap; var i,j:Integer; rowIn,rowOut:pRGBTriple; Bmp:TBitmap; Width,Height:Integer; begin Bmp:=TBitmap.Create; Bmp.Width := Bitmap.Height; Bmp.Height := Bitmap.Width; Bmp.PixelFormat := pf24bit; Width:=Bitmap.Width-1; Height
33、:=Bitmap.Height-1; for j := 0 to Height do begin rowIn := Bitmap.ScanLinej; for i := 0 to Width do begin rowOut := Bmp.ScanLinei; Inc(rowOut,Height - j; rowOut := rowIn; Inc(rowIn; end; end; Bitmap.Assign(Bmp; end; /旋转180度 procedure Rotate180(const Bitmap:TBitmap; var i,j:Integer; rowIn,rowOut:pRGBT
34、riple; Bmp:TBitmap; Width,Height:Integer; begin Bmp:=TBitmap.Create; Bmp.Width := Bitmap.Width; Bmp.Height := Bitmap.Height; Bmp.PixelFormat := pf24bit; Width:=Bitmap.Width-1; Height:=Bitmap.Height-1; for j := 0 to Height do begin rowIn := Bitmap.ScanLinej; for i := 0 to Width do begin rowOut := Bmp
35、.ScanLineHeight - j; Inc(rowOut,Width - i; rowOut := rowIn; Inc(rowIn; end; end; Bitmap.Assign(Bmp; end; /旋转270度 procedure Rotate270(const Bitmap:TBitmap; var i,j:Integer; rowIn,rowOu t:pRGBTriple; Bmp:TBitmap; Width,Height:Integer; begin Bmp:=TBitmap.Create; Bmp.Width := Bitmap.Height; Bmp.Height :
36、= Bitmap.Width; Bmp.PixelFormat := pf24bit; Width:=Bitmap.Width-1; Height:=Bitmap.Height-1; for j := 0 to Height do begin rowIn := Bitmap.ScanLinej; for i := 0 to Width do begin rowOut := Bmp.ScanLineWidth - i; Inc(rowOut,j; rowOut := rowIn; Inc(rowIn; end; end; Bitmap.Assign(Bmp; end; /任意角度 functio
37、n RotateBitmap(Bitmap:TBitmap;Angle:Integer;BackColor:TColor:TBitmap; var i,j,iOriginal,jOriginal,CosPoint,SinPoint : integer; RowOriginal,RowRotated : pRGBTriple; SinTheta,CosTheta : Extended; AngleAdd : integer; begin Result:=TBitmap.Create; Result.PixelFormat := pf24bit; Result.Canvas.Brush.Color
38、:=BackColor; Angle:=Angle Mod 360; if Angle<0 then Angle:=360-Abs(Angle; if Angle=0 then Result.Assign(Bitmap else if Angle=90 then begin Result.Assign(Bitmap; Rotate90(Result;/如果是旋转90度,直接调用上面的代码 end else if (Angle>90 and (Angle<180 then begin AngleAdd:=90; Angle:=Angle-AngleAdd; end else i
39、f Angle=180 then begin Result.Assign(Bitmap; Rotate180(Result;/如果是旋转180度,直接调用上面的过程 end else if (Angle>180 and (Angle<270 then begin AngleAdd:=180; Angle:=Angle-AngleAdd; end else if Angle=270 then begin Result.Assign(Bitmap; Rotate270(Result;/如果是旋转270度,直接调用上面的过程 end else if (Angle>270 and (
40、Angle<360 then begin AngleAdd:=270; Angle:=Angle-AngleAdd; end else AngleAdd:=0; if (Angle>0 and (Angle<90 then begin SinCos(Angle + AngleAdd * Pi / 180, SinTheta, CosTheta; if (SinTheta * CosTheta < 0 then begin Result.Width := Round(Abs(Bitmap.Width * CosTheta - Bitmap.Height * SinThet
41、a; Result.Height := Round(Abs(Bitmap.Width * SinTheta - Bitmap.Height * CosTheta; end else begin Result.Width := Round(Abs(Bitmap.Width * CosTheta + Bitmap.Height * SinTheta; Result.Height := Round(Abs(Bitmap.Width * SinTheta + Bitmap.Height * CosTheta; end; CosTheta:=Abs(CosTheta; SinTheta:=Abs(Sin
42、Theta; if (AngleAdd=0 or (AngleAdd=180 then begin CosPoint:=Round(Bitmap.Height*CosTheta; SinPoint:=Round(Bitmap.Height*SinTheta; end else begin SinPoint:=Round(Bitmap.Width*CosTheta; CosPoint:=Round(Bitmap.Width*SinTheta; end; for j := 0 to Result.Height-1 do begin RowRotated := Result.Scanlinej; f
43、or i := 0 to Result.Width-1 do begin Case AngleAdd of 0: begin jOriginal := Round(j+1*CosTheta-(i+1-SinPoint*SinTheta-1; iOriginal := Round(i+1*CosTheta-(CosPoint-j-1*SinTheta-1; end; 90: begin iOriginal := Round(j+1*SinTheta-(i+1-SinPoint*CosTheta-1; jOriginal := Bitmap.Height-Round(i+1*SinTheta-(C
44、osPoint-j-1*CosTheta; end; 180: begin j Original := Bitmap.Height-Round(j+1*CosTheta-(i+1-SinPoint*SinTheta; iOriginal := Bitmap.Width-Round(i+1*CosTheta-(CosPoint-j-1*SinTheta; end; 270: begin iOriginal := Bitmap.Width-Round(j+1*SinTheta-(i+1-SinPoint*CosTheta; jOriginal := Round(i+1*SinTheta-(CosP
45、oint-j-1*CosTheta-1; end; end; if (iOriginal >= 0 and (iOriginal <= Bitmap.Width-1and (jOriginal >= 0 and (jOriginal <= Bitmap.Height-1 then begin RowOriginal := Bitmap.ScanlinejOriginal; Inc(RowOriginal,iOriginal; RowRotated := RowOriginal; Inc(RowRotated; end else begin Inc(RowRotated;
46、 end; end; end; end; end; /水平翻转 procedure FlipHorz(const Bitmap:TBitmap; var i,j:Integer; rowIn,rowOut:pRGBTriple; Bmp:TBitmap; Width,Height:Integer; begin Bmp:=TBitmap.Create; Bmp.Width := Bitmap.Width; Bmp.Height := Bitmap.Height; Bmp.PixelFormat := pf24bit; Width:=Bitmap.Width-1; Height:=Bitmap.H
47、eight-1; for j := 0 to Height do begin rowIn := Bitmap.ScanLinej; for i := 0 to Width do begin rowOut := Bmp.ScanLinej; Inc(rowOut,Width - i; rowOut := rowIn; Inc(rowIn; end; end; Bitmap.Assign(Bmp; end; /垂直翻转 procedure FlipVert(const Bitmap:TBitmap; var i,j:Integer; rowIn,rowOut:pRGBTriple; Bmp:TBi
48、tmap; Width,Height:Integer; begin Bmp:=TBitmap.Create; Bmp.Width := Bitmap.Height; Bmp.Height := Bitmap.Width; Bmp.PixelFormat := pf24bit; Width:=Bitmap.Width-1; Height:=Bitmap.Height-1; for j := 0 to Height do begin rowIn := Bitmap.ScanLinej; for i := 0 to Width do begin rowOut := Bmp.ScanLineHeigh
49、t - j; Inc(rowOut,i; rowOut := rowIn; Inc(rowIn; end; end; Bitmap.Assign(Bmp; end; 亮度、对比度、饱和度的调整 以下代码用ScanLine配合指针移动实现! function Min(a, b: integer: integer; begin if a < b then result := a else result := b; end; function Max(a, b: integer: integer; begin if a > b then result := a else result :
50、= b; end; /亮度调整 procedure BrightnessChange(const SrcBmp,DestBmp:TBitmap;ValueChange:integer; var i, j: integer; SrcRGB, DestRGB: pRGBTriple; begin for i := 0 to SrcBmp.Height - 1 do begin SrcRGB := SrcBmp.ScanLinei; DestRGB := DestBmp.ScanLinei; for j := 0 to SrcBmp.Width - 1 do begin if ValueChange
51、 > 0 then begin DestRGB.rgbtRed := Min(255, SrcRGB.rgbtRed + ValueChange; DestRGB.rgbtGreen := Min(255, SrcRGB.rgbtGreen + ValueChange; DestRGB.rgbtBlue := Min(255, SrcRGB.rgbtBlue + ValueChange; end else begin DestRGB.rgbtRed := Max(0, SrcRGB.rgbtRed + ValueChange; DestRGB.rgbtGreen := Max(0, Sr
52、cRGB.rgbtGreen + ValueChange; DestRGB.rgbtBlue := Max(0, SrcRGB.rgbtBlue + ValueChange; end; Inc(SrcRGB; Inc(DestRGB; end; end; end; /对比度调整 procedure ContrastCh ange(const SrcBmp,DestBmp:TBitmap;ValueChange:integer; var i, j: integer; SrcRGB, DestRGB: pRGBTriple; begin for i := 0 to SrcBmp.Height -
53、1 do begin SrcRGB := SrcBmp.ScanLinei; DestRGB := DestBmp.ScanLinei; for j := 0 to SrcBmp.Width - 1 do begin if ValueChange>=0 then begin if SrcRGB.rgbtRed >= 128 then DestRGB.rgbtRed := Min(255, SrcRGB.rgbtRed + ValueChange else DestRGB.rgbtRed := Max(0, SrcRGB.rgbtRed - ValueChange; if SrcRG
54、B.rgbtGreen >= 128 then DestRGB.rgbtGreen := Min(255, SrcRGB.rgbtGreen + ValueChange else DestRGB.rgbtGreen := Max(0, SrcRGB.rgbtGreen - ValueChange; if SrcRGB.rgbtBlue >= 128 then DestRGB.rgbtBlue := Min(255, SrcRGB.rgbtBlue + ValueChange else DestRGB.rgbtBlue := Max(0, SrcRGB.rgbtBlue - Valu
55、eChange; end else begin if SrcRGB.rgbtRed >= 128 then DestRGB.rgbtRed := Max(128, SrcRGB.rgbtRed + ValueChange else DestRGB.rgbtRed := Min(128, SrcRGB.rgbtRed - ValueChange; if SrcRGB.rgbtGreen >= 128 then DestRGB.rgbtGreen := Max(128, SrcRGB.rgbtGreen + ValueChange else DestRGB.rgbtGreen := M
56、in(128, SrcRGB.rgbtGreen - ValueChange; if SrcRGB.rgbtBlue >= 128 then DestRGB.rgbtBlue := Max(128, SrcRGB.rgbtBlue + ValueChange else DestRGB.rgbtBlue := Min(128, SrcRGB.rgbtBlue - ValueChange; end; Inc(SrcRGB; Inc(DestRGB; end; end; end; /饱和度调整 procedure SaturationChange(const SrcBmp,DestBmp:TB
57、itmap;ValueChange:integer; var Grays: array0.767 of Integer; Alpha: array0.255 of Word; Gray, x, y: Integer; SrcRGB,DestRGB: pRGBTriple; i: Byte; begin ValueChange:=ValueChange+255; for i := 0 to 255 do Alphai := (i * ValueChange Shr 8; x := 0; for i := 0 to 255 do begin Gray := i - Alphai; Graysx :
58、= Gray; Inc(x; Graysx := Gray; Inc(x; Graysx := Gray; Inc(x; end; for y := 0 to SrcBmp.Height - 1 do begin SrcRGB := SrcBmp.ScanLineY; DestRGB := DestBmp.ScanLineY; for x := 0 to SrcBmp.Width - 1 do begin Gray := GraysSrcRGB.rgbtRed + SrcRGB.rgbtGreen + SrcRGB.rgbtBlue; if Gray + AlphaSrcRGB.rgbtRed
59、>0 then DestRGB.rgbtRed := Min(255,Gray + AlphaSrcRGB.rgbtRed else DestRGB.rgbtRed := 0; if Gray + AlphaSrcRGB.rgbtGreen>0 then DestRGB.rgbtGreen := Min(255,Gray + AlphaSrcRGB.rgbtGreen else DestRGB.rgbtGreen := 0; if Gray + AlphaSrcRGB.rgbtBlue>0 then DestRGB.rgbtBlue := Min(255,Gray + Alp
60、haSrcRGB.rgbtBlue else DestRGB.rgbtBlue := 0; Inc(SrcRGB; Inc(DestRGB; end; end; end; /RGB调整 procedure RGBChange(SrcBmp,DestBmp:TBitmap;RedChange,GreenChange,BlueChange:integer; var SrcRGB, DestRGB: pRGBTriple; i,j:integer; begin for i := 0 to SrcBmp.Height- 1 do begin SrcRGB := SrcBmp.ScanLinei; DestRGB :=DestBmp.Sca
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 江汉大学《行进管乐训练》2024-2025学年第二学期期末试卷
- 2026云南省昆明市寻甸县融媒体中心招聘1人笔试模拟试题及答案解析
- 《中国消防》杂志社招聘1人考试参考试题及答案解析
- 2026年宣城市人民医院(皖南医学院附属宣城医院)高层次人才招聘笔试备考题库及答案解析
- 2026福建厦门市集美区侨英小学产假顶岗教师招聘1人考试参考题库及答案解析
- 2026广东佛山市顺德区华南师范大学附属北滘学校招聘临聘教师笔试模拟试题及答案解析
- 修改完善内部管理制度
- 华为内部提建议制度
- 企业内部三项制度
- 保安内部品质部管理制度
- 中信建投笔试题库及答案
- 2026年江苏航空职业技术学院单招综合素质考试必刷测试卷必考题
- GB/T 26951-2025焊缝无损检测磁粉检测
- RTAF 009-2024 终端智能化分级研究报告
- 医院人事科人事专员笔试题库及答案解析
- 2025-2030中国沿海港口液体化工码头运营与布局规划报告
- 《国家十五五规划纲要》全文
- 2025年护士长选拔理论考核试题及答案
- 养老院护理流程培训
- 2026年黑龙江旅游职业技术学院单招职业倾向性考试必刷测试卷必考题
- (13)普通高中艺术课程标准日常修订版(2017年版2025年修订)
评论
0/150
提交评论