ورود

View Full Version : تبدیل عکس رنگی به حالت نگاتیو



vatal
دوشنبه 08 فروردین 1384, 23:57 عصر
با سلام :oops:

سوال من اینه که به چه شکل میشه یک عکس رنگی رو به به حالتی که توی نگاتیو

اون عکس است تبدیل کرد ؟

با تشکر : VATAL :sunglass:

m-khorsandi
سه شنبه 09 فروردین 1384, 10:42 صبح
درود

برای نوع BitMap میتونی از این Procedure استفاده کنی(اگه منظورت رو درست متوجه شده باشم)


const
MaxPixelCount = 32768;

type
pRGBArray = ^TRGBArray;
TRGBArray = ARRAY[0..MaxPixelCount-1] of TRGBTriple;


procedure NegativeBitmap(OrigBmp, DestBmp: TBitmap);
var i, j: integer;
tmpbmp: TBitmap;
OrigRow, DestRow: pRGBArray;
begin
tmpbmp := TBitmap.Create;

try
tmpbmp.Width := OrigBmp.Width;
tmpbmp.Height := OrigBmp.Height;
OrigBmp.PixelFormat := pf24bit;
tmpbmp.PixelFormat := OrigBmp.PixelFormat;

for i := 0 to tmpbmp.Height -1 do
begin
OrigRow := OrigBmp.ScanLine[i];
DestRow := tmpbmp.ScanLine[i];

for j := 0 to tmpbmp.Width - 1 do
begin
DestRow[j].rgbtRed := 255 - OrigRow[j].rgbtRed;
DestRow[j].rgbtGreen := 255 - OrigRow[j].rgbtGreen;
DestRow[j].rgbtBlue := 255 - OrigRow[j].rgbtBlue;
end;
end;

DestBmp.Assign(tmpbmp);
finally
tmpbmp.Free;
end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
NegativeBitmap(Image1.Picture.Bitmap, Image1.Picture.Bitmap);
end;

دوست عزیز
با استفاده از بلوک کد میتونی برنامه هات رو از نشون داده شدن به اون وضعیت فجیع نجات بدی.
با احترام
سپیدار