OnTheFly
OnTheFly

Reputation: 2101

Can i access TBits internal bitmap?

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?

Upvotes: 2

Views: 521

Answers (1)

LU RD
LU RD

Reputation: 34949

  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;

Upvotes: 9

Related Questions