两张BMP图片叠加

本文介绍了如何将两张BMP格式的图片进行叠加处理,详细阐述了图片读取、像素合并以及保存结果的步骤,包括使用RGB颜色模型进行像素级别的操作,并提供了相关代码示例。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

procedure BlendImage(BackBmp, ForeBmp: TBitmap; TransColor: TColor; Alpha: Integer);

type
  TRGBArray = array[0..32767] of TRGBTriple;
  PRGBArray = ^TRGBArray;

var
  X, Y, OffX, OffY: Integer;
  BackRect, ForeRect: TRect;
  BackRGB, ForeRGB: PRGBArray;
  BackR, BackG, BackB: Byte;
  ForeR, ForeG, ForeB: Byte;
begin
  if not Assigned(BackBmp) then exit;
  if not Assigned(ForeBmp) then exit;
  if BackBmp.PixelFormat <> pf24bit then Exit;
  if ForeBmp.PixelFormat <> pf24bit then Exit;
  if (BackBmp.Empty) or (ForeBmp.Empty) then Exit;
  BackRect := BackBmp.Canvas.ClipRect;
  ForeRect := ForeBmp.Canvas.ClipRect;
  DockRect(ForeRect, BackRect);
  OffX := ForeRect.Left - BackRect.Left;
  OffY := ForeRect.Top - BackRect.Top;
  for Y := 0 to BackBmp.Height - 1 do
  begin
    if (Y > ForeRect.Bottom - 1) or
      (Y < ForeRect.Top) then Continue;
    BackRGB := BackBmp.ScanLine[Y];
    ForeRGB := ForeBmp.ScanLine[Y 
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值