Can i access TBits internal bitmap?

此生再无相见时 提交于 2019-12-02 07:16:17

问题


In particular, i want to preset desired size, fetch a bitmap from external source, and then work with data in classy objecty-oriented manner.

I presume what

  1. TBits isnt just a straightforward collection of Booleans and
  2. internal storage is contiguous.

Am i correct with such assumptions?


回答1:


  1. Correct, TBits is internally bit-structured, so it's not a straightforward collection of booleans.
  2. Yes, storage is handled by allocating contiguous memory big enough to carry the size( in increments of SizeOf(integer)).

To get access to the internal data pointer, class helpers can be used.

Type
  TBitsHelper = class helper for TBits
    private
      function GetBitsPointer: Pointer;
    public
      property BitsPt: pointer read GetBitsPointer;
  end;

function TBitsHelper.GetBitsPointer: Pointer;
begin
  with Self do Result := FBits;  
end;


来源:https://stackoverflow.com/questions/11375619/can-i-access-tbits-internal-bitmap

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!