如何直接在FMX2中访问TBitmap像素(替换TBitmap.ScanLine)? [英] How to access TBitmap pixels directly in FMX2 (TBitmap.ScanLine replacement)?

查看:78
本文介绍了如何直接在FMX2中访问TBitmap像素(替换TBitmap.ScanLine)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

FMX.Types.TBitmap 类具有 ScanLine FMX(FireMonkey)中的属性,但似乎该属性已删除,而在FMX2(FireMonkey FM2)中却丢失.

The FMX.Types.TBitmap class has the ScanLine property in FMX (FireMonkey), but it seems this property was removed, and is missing in FMX2 (FireMonkey FM2).

有什么解决方法吗?我们应该如何直接在FMX2中访问 TBitmap 内容?

Is there any workaround ? How do we supposed to access TBitmap content directly in FMX2 ?

推荐答案

对于直接访问,您应该使用 FMX.AlphaColorToScanline :

For direct access you are expect to use the Map method. The documentation includes a number of examples, such as FMX.AlphaColorToScanline:

function TForm1.TestAlphaColorToScanline(ABitmap: TBitmap;
  start, count: integer): TBitmap;
var
  bitdata1, bitdata2: TBitmapData;
begin
  Result := TBitmap.Create(Round(ABitmap.Width), Round(count));
  if (ABitmap.Map(TMapAccess.maRead, bitdata1) and
    Result.Map(TMapAccess.maWrite, bitdata2)) then
  begin
    try
      AlphaColorToScanline(@PAlphaColorArray(bitdata1.Data)
        [start * (bitdata1.Pitch div GetPixelFormatBytes(ABitmap.PixelFormat))],
        bitdata2.Data, Round(Result.Height * Result.Width),
        ABitmap.PixelFormat);
    finally
      ABitmap.Unmap(bitdata1);
      Result.Unmap(bitdata2);
    end;
  end;
end;

这篇关于如何直接在FMX2中访问TBitmap像素(替换TBitmap.ScanLine)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆