Delphi-PRAXiS
Seite 1 von 2  1 2      

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   GUI-Design mit VCL / FireMonkey / Common Controls (https://www.delphipraxis.net/18-gui-design-mit-vcl-firemonkey-common-controls/)
-   -   Delphi XE7 - ZintBarcode Exception (https://www.delphipraxis.net/191790-xe7-zintbarcode-exception.html)

canoniac 20. Feb 2017 07:20

XE7 - ZintBarcode Exception
 
Hallo zusammen,

ich habe folgendes Problem:
Ich Verwende in zwei Projekten die ZintBarcode - Komponente. In einem der Projekte lässt sich ein Barcode ohne Fehler erstellen, im anderen Fall kommt es zu einer Exception ("Systemressourcen erschöpft"). Bei der Fehlersuche habe ich den Code auf ein minimum reduziert und die entsprechende dll sowie die nötigen Units direkt aus dem funktionierenden Projektverzeichnis kopiert. Die "Hauptform" enthält nichts weiter als den angefügten Code. Die Exception tritt beim Aufruf von MyBarcode.GetBarcode() auf.

Delphi-Quellcode:
procedure THauptForm.FormCreate(Sender: TObject);
var
    MyBitmap     :TBitMap;
    MyBarcode    :TZintBarcode;

begin
  //BarCode zeichnen ***********************************************************
  MyBarcode := TZintBarcode.Create;
  MyBarcode.Clear;
  MyBarcode.Data := '00340311640213278478';
  MyBarcode.BarcodeType := tBARCODE_CODE128;
  MyBarcode.Option3     := 100;
  MyBarcode.Scale      := 1;
  MyBarcode.GetBarcode(MyBitmap);
//  MyCanvas.Draw(0,0,MyBitmap);
  //****************************************************************************

end;
Die Frage ist nun: Wie kann das sein? :-D

Für Tipps wäre ich sehr Dankbar! :)

Danke im Voraus
canoniac

Rollo62 20. Feb 2017 10:23

AW: XE7 - ZintBarcode Exception
 
Kann es sein das es daran liegt dass das TBitmap nicht erzeugt ist ?

Delphi-Quellcode:
procedure ZeichneBarcode;
var
  myBmp :TBitMap;
  myZintBarcode :TZintBarcode;
begin

  myZintBarcode := TZintBarcode.Create;
  myBmp := TBitmap.Create;


  myZintBarcode.Clear;
  myZintBarcode.Data := '00340311640213278478';
  myZintBarcode.BarcodeType := tBARCODE_CODE128;
  myZintBarcode.Option3 := 100;
  myZintBarcode.Scale := 1;
  myZintBarcode.GetBarcode(myBmp);
  Form1.Canvas.Draw(0,0,myBmp);



  myBmp.Free;
  myZintBarcode.Free;
end;
Rollo

canoniac 20. Feb 2017 12:15

AW: XE7 - ZintBarcode Exception
 
Au...in meinen Projekten ist es natürlich erzeugt.

Delphi-Quellcode:
procedure THauptForm.FormCreate(Sender: TObject);
var
    MyBitmap     :TBitMap;
    MyBarcode    :TZintBarcode;

begin
  //BarCode zeichnen ***********************************************************
  MyBarcode := TZintBarcode.Create;
  MyBitmap := TBitMap.Create;
  MyBarcode.Clear;
  MyBarcode.Data := '00340311640213278478';
  MyBarcode.BarcodeType := tBARCODE_CODE128;
  MyBarcode.Option3     := 100;
  MyBarcode.Scale      := 1;
  MyBarcode.GetBarcode(MyBitmap);
//  MyCanvas.Draw(0,0,MyBitmap);
  //****************************************************************************

end;

haentschman 20. Feb 2017 13:37

AW: XE7 - ZintBarcode Exception
 
Hallöle...:P
Delphi-Quellcode:
myBmp.Free;
myZintBarcode.Free;
...wie es schon Rollo62 sagte. (:wink: erinnert mich immer an https://de.wikipedia.org/wiki/Wilde_Kreaturen)

canoniac 20. Feb 2017 13:49

AW: XE7 - ZintBarcode Exception
 
Die Objekte müssen freigegeben werden. Das ist schon klar.
Aber dennoch muss sich ja ein Bitmap erstellen lassen BEVOR das Objekt zerstört wird.

Ich habe das an der Stelle dann mal eingefügt - an dem beschriebenen Verhalten ändert sich jedoch nichts...

Rollo62 20. Feb 2017 15:29

AW: XE7 - ZintBarcode Exception
 
So ungefähr funktioniert es bei mir.

Vielleicht liegts am .Refresh ?


Delphi-Quellcode:
procedure TForm1.ActionQrGenerateSingleExecute;
var
  bmpQr: TBitmap;
  picQr: TJpegImage;

begin

 ZintBarcodeComponent1.Barcode.Scale := SpinEditScale.Value / 100.0;

 ZintBarcodeComponent1.Barcode.Data := strX;
 ZintBarcodeComponent1.Refresh;

 //
 // Get Barcode
 //
 bmpQr := TBitmap.Create;
 picQr := TJpegImage.Create;

 try

   ZintBarcodeComponent1.Barcode.GetBarcode(bmpQr);

   picQr.Assign(bmpQr);
   picQr.CompressionQuality := 80;
   picQr.SaveToFile( strFile + '.jpg'); // Save as JPEG

 finally

   FreeAndNil(picQr);
   FreeAndNil(bmpQr);

 end;

end;

canoniac 21. Feb 2017 08:39

AW: XE7 - ZintBarcode Exception
 
Danke für den Tipp, leider verursacht der Aufruf von GetBarcode() immernoch eine Exception.

Ist es möglich dass -wie auch immer- unterschiedliche Projekteinstellungen vorliegen?
Und wenn das eine Möglichkeit ist, wo finde ich die betreffenden Einstellungen?

FaTaLGuiLLoTiNe 21. Feb 2017 10:29

AW: XE7 - ZintBarcode Exception
 
Könnte das Problem an dem Aufruf im FormCreate-Event liegen?

Rollo62 21. Feb 2017 12:23

AW: XE7 - ZintBarcode Exception
 
Das sind die Einstellungen in der Form dazu ...
Bei mir gehts aber um QR-Code.

Delphi-Quellcode:
    object ZintBarcodeComponent1: TZintBarcodeComponent
      Left = 0
      Top = 73
      Width = 653
      Height = 519
      Align = alClient
      Barcode.BarcodeType = tBARCODE_QRCODE
      Barcode.Data = 'http://example.de'
      Barcode.Height = 25
      Barcode.BorderWidth = 1
      Barcode.OutputOptions = []
      Barcode.FGColor = clBlack
      Barcode.BGColor = clWhite
      Barcode.Option1 = -1
      Barcode.Option2 = 0
      Barcode.Option3 = 928
      Barcode.Rotation = r0
      Barcode.ShowHumanReadableText = True
      Barcode.Stacked = False
      ExplicitLeft = 232
      ExplicitTop = 176
      ExplicitWidth = 100
      ExplicitHeight = 41
    end
Rollo

canoniac 21. Feb 2017 13:37

AW: XE7 - ZintBarcode Exception
 
Vielen Dank, für die Rückmeldungen.

Leider wird mir trotz alle dem immernoch nicht klar wieso der gleiche Code in zwei unterschiedlichen
Projekten nicht gleich gut / schlecht funktioniert.

Das Problem ließ sich jetzt "lösen" oder eher gesagt umgehen indem ich ein komplett neues Projekt erstellt habe.:gruebel:

Könnte mir jemand erläutern wo ich beispielsweise Einstelllungen und Eigenschaften die beim Compilieren, Linken und Erstellen des Projekts zum tragen kommen finde?
Ich vermute das die Ursache in einer fehlerhaften oder inkompatiblen Einstellung liegen könnte.

Kann das evtl. jemand, im Zusammenhang mit anderen Komponenten, bestätigen?


Alle Zeitangaben in WEZ +1. Es ist jetzt 21:02 Uhr.
Seite 1 von 2  1 2      

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