procedure TForm3.Button3Click(Sender: TObject);
type
TRGBTripleArray=Array[0..32768-1] of TRGBTriple;
pRGBTripleArray=^TRGBTripleArray;
var
i,j,bmpheight,bmpwidth:integer;
imageshifted,imageunshifted:pRGBTripleArray;
originX,originY,
TX,TY: integer;
newbmp,tempbmp:Tbitmap;begin
newbmp:=Tbitmap.Create;
tempbmp:=Tbitmap.Create;
tempbmp.PixelFormat:=pf24bit;
tempbmp.Width:=image1.Width;
tempbmp.height:=image1.height;
tempbmp.Canvas.Draw(0,0,image1.Picture.Graphic);
newbmp.Width:=tempbmp.Width;
newbmp.height:=tempbmp.height;
bmpwidth:=tempbmp.Width;
bmpheight:=tempbmp.height;
TX:=10;
TY:=10;
for j:=bmpheight-1 downto 0 do
begin
imageshifted:=newbmp.scanline[j];
for i:=bmpwidth-1 downto 0 do
begin
originX:=i-TX;
originY:=j-TY;
if (originX >0)and (originX <bmpwidth-1)and (originY >0)and (originY <bmpheight-1) then
begin
imageunshifted:=tempbmp.scanline[originY];
imageshifted[i]:=imageunshifted[originX];
end
else
begin
imageshifted[i].rgbtRed:=255;
imageshifted[i].rgbtGreen:=255;
imageshifted[i].rgbtBlue:=255;
end;
end;
end;
image1.Picture.Bitmap.Assign(newbmp);
newbmp.Free;
tempbmp.Free;
end;
type
TRGBTripleArray=Array[0..32768-1] of TRGBTriple;
pRGBTripleArray=^TRGBTripleArray;
var
i,j,bmpheight,bmpwidth:integer;
imageshifted,imageunshifted:pRGBTripleArray;
originX,originY,
TX,TY: integer;
newbmp,tempbmp:Tbitmap;begin
newbmp:=Tbitmap.Create;
tempbmp:=Tbitmap.Create;
tempbmp.PixelFormat:=pf24bit;
tempbmp.Width:=image1.Width;
tempbmp.height:=image1.height;
tempbmp.Canvas.Draw(0,0,image1.Picture.Graphic);
newbmp.Width:=tempbmp.Width;
newbmp.height:=tempbmp.height;
bmpwidth:=tempbmp.Width;
bmpheight:=tempbmp.height;
TX:=10;
TY:=10;
for j:=bmpheight-1 downto 0 do
begin
imageshifted:=newbmp.scanline[j];
for i:=bmpwidth-1 downto 0 do
begin
originX:=i-TX;
originY:=j-TY;
if (originX >0)and (originX <bmpwidth-1)and (originY >0)and (originY <bmpheight-1) then
begin
imageunshifted:=tempbmp.scanline[originY];
imageshifted[i]:=imageunshifted[originX];
end
else
begin
imageshifted[i].rgbtRed:=255;
imageshifted[i].rgbtGreen:=255;
imageshifted[i].rgbtBlue:=255;
end;
end;
end;
image1.Picture.Bitmap.Assign(newbmp);
newbmp.Free;
tempbmp.Free;
end;
什么关系也没有,你打开newbmp能不白嘛
newbmp.PixelFormat:=pf24bit;
newbmp.PixelFormat:=pf24bit;}
相当正确! 谢谢啦