![]() |
Fehler bei Bereichsprüfung für ein bitmap drehen
Hallo,
ich habe ein Problem und zwar,dass mein programm ein fehler Meldung (Fehler bei Bereichsprüfung)ausliefert.
Delphi-Quellcode:
type TRGBarray = array[0..0] of TRGBQuad;
procedure TFormFoto.rotate90(const Source:TGraphic ; Bmp: TBitmap); var P : PRGBQuad; y, x, h, b: integer; Rowout : ^TRGBarray; sourcebmp : TBitmap; begin sourcebmp := TBitmap.Create; try sourcebmp.PixelFormat := pf32bit; sourcebmp.Height := Source.Height; sourcebmp.Width := Source.Width; sourcebmp.Canvas.Draw(0, 0, Source); Bmp.PixelFormat := pf32bit; b := sourcebmp.Height; h := sourcebmp.Width; Bmp.Height := h; Bmp.Width := b; for y := 0 to (h - 1) do begin rowout := Bmp.ScanLine[y]; p := sourcebmp.ScanLine[sourcebmp.height-1]; inc(p, y); for x := 0 to (b-1) do begin rowout[x] := p^; inc(p, h); end; end; finally sourcebmp.Free; end; end; |
AW: Fehler bei Bereichsprüfung für ein bitmap drehen
Zitat:
...:cat:... |
AW: Bereichsüberlauf bei rin bitmap drehen
Zitat:
Delphi-Quellcode:
definiert ist und Du dann später hemmunglos einen Index > 0 verwendest:
type TRGBarray = array[0..0] of TRGBQuad;
Delphi-Quellcode:
Entweder Du schaltets die Bereichsüberprüfung für diese Methode aus ({$R-}) oder deklarierst den Typ z. B. alsprocedure TFormFoto.rotate90(const Source:TGraphic ; Bmp: TBitmap); var P : PRGBQuad; y, x, h, b: integer; Rowout : ^TRGBarray; sourcebmp : TBitmap; begin .... rowout[x] := p^; end;
Delphi-Quellcode:
Mit dieser Deklaration darfst Du aber auf keinen Fall eine Variable dieses Typs deklarieren, die würde 4 GByte Speicher belegen! Mti einem Pointer darauf zu arbeiten ist aber kein Problem.
type TRGBarray = array[0..(High(Cardinal) div Sizeof(TRGBQuad))-1] of TRGBQuad;
|
AW: Fehler bei Bereichsprüfung für ein bitmap drehen
Zitat:
mein Fehler triit in dieser Zeile auf:
Delphi-Quellcode:
rowout[x] := p^;
|
AW: Bereichsüberlauf bei rin bitmap drehen
Zitat:
Danke für die Antwort. ich habe vorher es versucht :
Delphi-Quellcode:
aber es tritt ein Fehler auf: E2100 Datentyp zu groß:2 GB überschritten:(
type TRGBarray = array[0..(High(Cardinal) div Sizeof(TRGBQuad))-1] of TRGBQuad;
|
AW: Bereichsüberlauf bei rin bitmap drehen
Zitat:
Delphi-Quellcode:
...:cat:...
type TRGBarray = array of TRGBQuad;
|
AW: Bereichsüberlauf bei rin bitmap drehen
Zitat:
|
AW: Bereichsüberlauf bei rin bitmap drehen
Zitat:
Aber das geht:
Delphi-Quellcode:
...:cat:...
procedure Rotate90(const aSource:TGraphic; const aBmp: TBitmap);
var SourceBmp : TBitmap; SourcePixel, DestPixel: PRGBQuad; Y, X, SourceWidth, SourceHeight: Integer; begin SourceBmp := TBitmap.Create; try SourceBmp.PixelFormat := pf32bit; SourceBmp.Height := aSource.Height; SourceBmp.Width := aSource.Width; SourceBmp.Canvas.Draw(0, 0, aSource); SourceHeight := SourceBmp.Height; SourceWidth := SourceBmp.Width; aBmp.PixelFormat := pf32bit; aBmp.Height := SourceWidth; aBmp.Width := SourceHeight; for Y := 0 to SourceWidth - 1 do begin DestPixel := aBmp.ScanLine[Y]; SourcePixel := SourceBmp.ScanLine[SourceBmp.Height - 1]; Inc(SourcePixel, Y); for X := 0 to SourceHeight - 1 do begin DestPixel^ := SourcePixel^; Inc(SourcePixel, SourceWidth); Inc(DestPixel); end; end; finally SourceBmp.Free; end; end; |
AW: Fehler bei Bereichsprüfung für ein bitmap drehen
Delphi-Quellcode:
Es wird von Annahmen ausgegangen, die nicht unbedingt so sein müssen:
...
Inc(SourcePixel, SourceWidth); - jede Zeile belegt nur so viel Speicher, wie für die Pixel unbedingt erforderlich ist - die Zeilen liegen in absteigender Reihenfolge im Speicher |
AW: Bereichsüberlauf bei rin bitmap drehen
Zitat:
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 09:25 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz