System Resources - How Many Is Too Many?

procedure TAdvToolButton.SetGlyph(Value: TBitmap);
var
  x,y: Integer;
  PxlColor: TColor;
  c: byte;
begin
  FGlyph.Assign(Value);
  //if no disabled glyph is given... add this automatically...
  if FGlyphDisabled.Empty then
  begin
    FGlyphDisabled.Assign(Value);
    for x := 0 to FGlyphDisabled.Width - 1 do
      for y := 0 to FGlyphDisabled.Height - 1 do
      begin
        PxlColor := ColorToRGB(FGlyphDisabled.Canvas.Pixels[x, y]);
        c := Round((((PxlColor shr 16) + ((PxlColor shr 8) and $00FF) +
               (PxlColor and $0000FF)) div 3)) div 2 + 96;
        FGlyphDisabled.Canvas.Pixels[x, y] := RGB(c, c, c);
      end;
  end;
  Invalidate;
end;

I’m a bit confused.
In your code above by a couple, GetBitmap copies imagelist [2] and [3] into BtPause .Glyph and .GlyphDisabled.

Calling this function passes in a (pointer to a) Bitmap … in order to reprocess the colouring, I think??

.Assign copies the pointed to object. Shouldn’t this procedure just have one job - to do the colour change?

[edit] I guess I am asking

  • what is the job of this procedure?
  • what are the preconditions on entering it?
  • what are the postconditions on leaving it?

I’ve rechecked and the auto generation of the disabled glyph in that component works fine so only need to set the enabled one now.