AW: Grafik im Speicher erstellen für BlobStream (DB)
Vielen Dank, Du hast mir sehr geholfen :-)
PS: gibt es schon eine fertige Funktion, um ein Zufallsbild zu erzeugen? LG |
AW: Grafik im Speicher erstellen für BlobStream (DB)
nicht das ich wüsste, aber per iteration (über width und height) kannst du bunte punkte setzen...
Zitat:
|
AW: Grafik im Speicher erstellen für BlobStream (DB)
nur mal auf die schnelle dahingedaddelt. erwarte keine wunder.
Delphi-Quellcode:
procedure TForm9.FormCreate(Sender: TObject);
type TRGB = record b,g,r: Byte; end; ARGB = array [0..1] of TRGB; PARGB = ^ARGB; var p: PARGB; x,y: Integer; bmp: Vcl.Graphics.TBitmap; begin bmp := Vcl.Graphics.TBitmap.Create; try bmp.PixelFormat := pf24bit; bmp.Width := 50; bmp.Height := 50; for y := 0 to (bmp.Height - 1) do begin p := bmp.ScanLine[y]; for x := 0 to (bmp.Width - 1) do begin p[x].r := Random(High(Byte)); p[x].g := Random(High(Byte)); p[x].b := Random(High(Byte)); end; end; // mach was... finally bmp.Free; end; end; |
AW: Grafik im Speicher erstellen für BlobStream (DB)
Das ist nett :-)
:-D |
AW: Grafik im Speicher erstellen für BlobStream (DB)
Ps: Randomize << das noch aufrufen bevor Random() aufgerufen wird, habs vergessen im oberen source.
|
AW: Grafik im Speicher erstellen für BlobStream (DB)
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 :-) |
AW: Grafik im Speicher erstellen für BlobStream (DB)
Delphi-Quellcode:
minimal abgeändert, jedenfalls würde es so bei mir aussehen.
function RandomBitmap(Abmp: VCL.Graphics.TBitmap; const AWidth: Integer = 225; const AHeight: Integer = 225): Boolean;
type TRGB = record b, g, r: Byte; end; ARGB = array [0 .. 1] of TRGB; PARGB = ^ARGB; var x, y: Integer; p: PARGB; begin Result := False; if (AWidth = 0) or (AHeight = 0) then Exit(False); Randomize; if Abmp = nil then Abmp := Vcl.Graphics.TBitmap.Create; try Abmp.PixelFormat := pf24bit; Abmp.Width := AWidth; Abmp.Height := AHeight; for y := 0 to (Abmp.Height - 1) do begin p := Abmp.ScanLine[y]; for x := 0 to (Abmp.Width - 1) do begin p[x].r := Random(High(Byte)); p[x].g := Random(High(Byte)); p[x].b := Random(High(Byte)); end; end; finally Result := True; end; end; |
AW: Grafik im Speicher erstellen für BlobStream (DB)
Und den Speicher hast Du im Griff?
|
AW: Grafik im Speicher erstellen für BlobStream (DB)
Zitat:
Delphi-Quellcode:
?
if Abmp = nil then
Abmp := Vcl.Graphics.TBitmap.Create; Das würde bei mir auch mittels Exit, bei nil, vorher abgefangen werden. Hatte ich in meinem Code vergessen. LG |
AW: Grafik im Speicher erstellen für BlobStream (DB)
Zitat:
(kein objekt da = erschaffe eins, ist eins da = mach was) //edit (ich gebe solche objekte per freeandnil frei) |
Alle Zeitangaben in WEZ +1. Es ist jetzt 15:58 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz