Einzelnen Beitrag anzeigen

Benutzerbild von NoGAD
NoGAD

Registriert seit: 31. Jan 2006
Ort: Weimar
344 Beiträge
 
Delphi 10.4 Sydney
 
#16

AW: Grafik im Speicher erstellen für BlobStream (DB)

  Alt 20. Apr 2021, 01:15
Danke nochmal, ich habe es in eine Function gegossen:


Delphi-Quellcode:

type
  TRGB = record
    b, g, r: Byte;
  end;

  ARGB = array [0 .. 1] of TRGB;
  PARGB = ^ARGB;


function RandomBitmap(bmp: VCL.Graphics.TBitmap; iWidth: Integer = 225; iHeight: Integer = 225): Boolean;
var
  ix, iy: Integer;
  p: PARGB;
begin

  Result := default (Boolean);

  if (iWidth = 0) and (iHeight = 0) then
    exit;

  Randomize;
  try
    bmp.PixelFormat := pf24bit;
    bmp.Width := iWidth;
    bmp.Height := iHeight;
    for iy := 0 to (bmp.Height - 1) do
    begin
      p := bmp.ScanLine[iy];
      for ix := 0 to (bmp.Width - 1) do
      begin
        p[ix].r := random(High(Byte));
        p[ix].g := random(High(Byte));
        p[ix].b := random(High(Byte));
      end;
    end;
  finally
    Result := true;
  end;

end;


// Aufruf z.B.:

var
  Dummy_Image: Vcl.Graphics.TBitmap;
begin
  Dummy_Image := Vcl.Graphics.TBitmap.Create;
  RandomBitmap(Dummy_Image, random(50) + 225, random(50) + 225);
// hier was mit dem Bild machen
  Dummy_Image.Free;
end;

LG und schlaf gut
Mathias
Ich vergesse einfach zu viel.
  Mit Zitat antworten Zitat