Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Abspeichern eines *.jpg Bildes

Empfohlene Antworten

Veröffentlicht

Hallo,

Ich versuche mit dem C++ Builder ein Programm zu schreiben, mit dem ich Bilder im *.jpg Format abspeichern kann.

Aber der folgende Programmteil produziert immer wieder einen Fehler (Unerlaubter Speicherzugriff):



#include <jpeg.hpp>


void __fastcall TForm1::Button6Click(TObject *Sender)

{

  TJPEGImage *jpg = new TJPEGImage();


  if (SaveDialog1->Execute())

  {

    if (FileExists(SaveDialog1->FileName))

    {

      int i = Application -> MessageBox

        ("Datei existiert bereits", "Warnung",   

              MB_YESNOCANCEL);

//      if ( i==6 )

//        DBImage1->Picture->SaveToFile(SaveDialog1-

//              >FileName);

    }

    else

      jpg = (TJPEGImage *)DBImage1->Picture;

      jpg -> SaveToFile(SaveDialog1->FileName);

  }

  delete jpg;

}

Kann mir jemand sagen, warum das so ist und mir helfen, damit das nicht mehr passiert?

Vielleicht liegt's ja daran:

Du erstellst am Anfang ein TJPEGImage-Objekt per


TJPEGImage *jpg = new TJPEGImage();

(*)Dann setzt du die Varibale jpg auf einen neuen Wert:

jpg = (TJPEGImage *)DBImage1->Picture;

Von nun an hast du keine Kontrolle mehr über das eben erstellt TJPEGImage-Objekt. Schließlich gibst du das Objekt wieder frei:

delete jpg;

Nach der Zuweisung bei (*) gibt du aber so ein

TJPEGImage-Objekt an der Speicheradresse von

DBImage1->Picture frei!!!

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.