AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Multimedia D5 + GraphicEx - .jpg will nicht
Thema durchsuchen
Ansicht
Themen-Optionen

D5 + GraphicEx - .jpg will nicht

Ein Thema von miriki · begonnen am 20. Aug 2013 · letzter Beitrag vom 8. Sep 2013
 
miriki

Registriert seit: 20. Aug 2013
Ort: Kiel
3 Beiträge
 
Delphi 5 Enterprise
 
#1

D5 + GraphicEx - .jpg will nicht

  Alt 20. Aug 2013, 20:47
Moinsens!

Ich versuche gerade, ein (mehr oder weniger beliebiges) Bild zu erzeugen / laden, es (ggf. ausschnittsweise) auf ein anderes zu kopieren und das Ergebnis dann auf einem Form anzuzeigen.

Der erste Versuch mit .bmp verlief soweit ganz gut, aber ich brauchte ein paar mehr Formate, als mein altes Delphi 5 hergeben wollte. Und ich wollte mir Code-Weichen je nach Bildformat gerne sparen. GraphicEx schien da ein guter Weg zu sein.

Nach Einbinden der GraphicEx-Unit klappte es auch auf Anhieb mit .png und .pcx Grafiken. Und eine kleine Änderung in der Konfiguration ermöglichte dann auch .gif Bilder. (Weitere Formate habe ich bislang nicht getestet.)

Was ich aber auf Teufel komm raus nicht hinbekomme: .jpg Bilder - die resultieren in einem leeren Image.

Die "Kern"-Routine aus einem Test-Projekt:
Code:
procedure tform1.loadimage( f:string );
var
  src_image: timage;
  src_picture: tpicture;
  src_graphic: tgraphic;
  src_bitmap: tbitmap;
  src_canvas: tcanvas;
  src_x1, src_y1, src_x2, src_y2: integer;
  src_rect: trect;
  mid_image: timage;
  mid_picture: tpicture;
  mid_graphic: tgraphic;
  mid_bitmap: tbitmap;
  mid_canvas: tcanvas;
  mid_x1, mid_y1, mid_x2, mid_y2: integer;
  mid_rect: trect;
  dst_image: timage;
  dst_picture: tpicture;
  dst_graphic: tgraphic;
  dst_bitmap: tbitmap;
  dst_canvas: tcanvas;
  dst_x1, dst_y1, dst_x2, dst_y2: integer;
  dst_rect: trect;
begin
  if ( f <> '' ) then begin

    // ------------------------------------------------------------
    // image used to display the combined image on a form
    // (centered and stretched)
    // ------------------------------------------------------------
    dst_image := gfx_image;
    dst_picture := dst_image.picture;
    //dst_graphic := dst_picture.graphic;
    //dst_bitmap := dst_picture.bitmap;
    //dst_canvas := dst_bitmap.canvas;
    //dst_x1 := 0;
    //dst_y1 := 0;
    //dst_x2 := gfx_image.width - 1;
    //dst_y2 := gfx_image.height - 1;
    //dst_rect := rect( dst_x1, dst_y1, dst_x2, dst_y2 );

    // ------------------------------------------------------------
    // load the desired image
    // ------------------------------------------------------------
    src_picture := tpicture.create;
    src_picture.loadfromfile( f );
    //src_graphic := src_picture.graphic;
    src_bitmap := src_picture.bitmap;
    src_canvas := src_bitmap.canvas;
    src_x1 := 0;
    src_y1 := 0;
    src_x2 := src_bitmap.width - 1;
    src_y2 := src_bitmap.height - 1;
    src_rect := rect( src_x1, src_y1, src_x2, src_y2 );

    // ------------------------------------------------------------
    // prepare a canvas to hold the loaded image
    // ------------------------------------------------------------
    mid_picture := tpicture.create;
    //mid_graphic := mid_picture.graphic;
    mid_bitmap := mid_picture.bitmap;
    mid_bitmap.width := src_bitmap.width + 200;
    mid_bitmap.height := src_bitmap.height + 200;
    mid_canvas := mid_bitmap.canvas;
    mid_x1 := 100;
    mid_y1 := 100;
    mid_x2 := mid_x1 + ( src_x2 - src_x1 );
    mid_y2 := mid_y1 + ( src_y2 - src_y1 );
    mid_rect := rect( mid_x1, mid_y1, mid_x2, mid_y2 );

    // ------------------------------------------------------------
    // copy the loaded image onto the prepared canvas
    // ------------------------------------------------------------
    mid_canvas.copyrect( mid_rect, src_canvas, src_rect );

    // ------------------------------------------------------------
    // assign the combined image to the image on the form
    // ------------------------------------------------------------
    dst_picture.assign( mid_bitmap );

  end;
end;
Vielleicht kann mir hier jemand sagen, was ich für .jpg anpassen muß...

Was ich letztendlich brauche, sofern es für die Anpassung relevant ist:
a) Das Original des aus der Datei geladenen Bildes im Speicher, nicht zugeschnitten, skaliert oder sonstwas. Das Bild liegt wahrscheinlich im Bereich von 800x600 bis 1920x1080.
b) Das Original des Canvas, auf dem sich eine Kopie des Bildes aus a) befindet. Das Ding kann auch schon leicht mal 4000x4000 groß werden. Dieser Canvas muß als .bmp speicherbar sein.
c) eine Darstellung von b) auf dem Form, wobei die Breite vorgegeben ist (align:bottom) und ich die Höhe anpasse, damit das Seitenverhältnis von b) erhalten bleibt.
... und a) ist im eigentlichen Projekt ein Array aus mehreren (z.Z. bis zu 8) Bildern.

Gruß, Michael
Michael
  Mit Zitat antworten Zitat
 

 

Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 01:18 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