AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein GUI-Design mit VCL / FireMonkey / Common Controls Mobile: Wie können dem ImageViewer1 verschiedene .jpgs zugewiesen werden?
Thema durchsuchen
Ansicht
Themen-Optionen

Mobile: Wie können dem ImageViewer1 verschiedene .jpgs zugewiesen werden?

Ein Thema von Sel2012 · begonnen am 1. Nov 2015 · letzter Beitrag vom 3. Nov 2015
Antwort Antwort
Sel2012

Registriert seit: 6. Jun 2015
Ort: 31535
103 Beiträge
 
Delphi XE5 Professional
 
#1

AW: Mobile: Wie können dem ImageViewer1 verschiedene .jpgs zugewiesen werden?

  Alt 2. Nov 2015, 16:33
Ich verstehe nicht das Problem,
in meiner AndroidApp lade ich zum Start alle meine Bildernamen aus dem FotoOrdner in eine ListBox und beim Klick in die ListBox
lasse ich mir das Bild in einem anderen Tab als Vorschau anzeigen.Dazu reichen 2 Zeilen.

Delphi-Quellcode:
  Image1.Bitmap.LoadFromFile('/storage/emulated/0/DCIM/camera/' + ListBox1.Selected.Text);
  TabControl1.TabIndex := 1;
...und meine KameraBilder sind Jpg's
Und weil es jpgs sind, scheint es doch ein Problem zu sein - jedenfalls bei mir. Der aufmerksame Leser hat schon festgestellt, das Sir Rufos Vorschlag mit jpgs nicht klappte.
Auch Olli73 schlägt Image1.Bitmap.LoadFromFile('MeineJpegDateiInklusiveVollständigemPfad.jpg'); vor.
Das gibt mir doch zu denken. Deshalb hier meine (nicht funktionierende) Version.
Delphi-Quellcode:
unit Unit3;

interface

uses
  System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
  FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.ListBox,
  FMX.Layouts, FMX.StdCtrls, FMX.Objects, FMX.TabControl;

type
  TForm3 = class(TForm)
    Image1: TImage;
    Button1: TButton;
    ListBox1: TListBox;
    ListBoxItem1: TListBoxItem;
    ListBoxItem2: TListBoxItem;
    ListBoxItem3: TListBoxItem;
    ListBoxItem4: TListBoxItem;
    TabControl1: TTabControl;
    procedure Button1Click(Sender: TObject);

  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form3: TForm3;

implementation

{$R *.fmx}

procedure TForm3.Button1Click(Sender: TObject);
begin
    Image1.Bitmap:=TBitmap.create;
  Image1.Bitmap.LoadFromFile('C:\Users\u\Pictures\Goethe\' + ListBox1.Selected.Text);
  TabControl1.TabIndex := 1;
end;

end.
Findet jemand den Fehler?
  Mit Zitat antworten Zitat
mensch72

Registriert seit: 6. Feb 2008
838 Beiträge
 
#2

AW: Mobile: Wie können dem ImageViewer1 verschiedene .jpgs zugewiesen werden?

  Alt 2. Nov 2015, 16:50
google: "fmx load jpg"

-> http://stackoverflow.com/questions/2...ling-in-delphi
In FireMonkey, graphics are handled using specialized classes derived from FMX.Graphics.TCustomBitmapCodec that are registered with the FMX.Graphics.TBitmapCodecManager class. You use the general-purpose FMX.Graphics.TBitmap class for handling all graphics. When loading a graphic, it uses the appropriate registered codec (if it can find one), but when saving you have to specify the codec you want to use.

FireMonkey uses different codec implementations for each platform, thus there is no single class that you can subclass, like there is in VCL. So, in order to customize JPEG handling in FireMonkey, you will have to create your own TCustomBitmapCodec-derived codec and register it with TBitmapCodecManager (unregistering the existing classes for the .jpg and .jpeg file extensions). Here are the codec classes that FireMonkey currently implements:

Windows: TBitmapCodecWIC in FMX.Canvas.D2D.pas
OSX: TBitmapCodecQuartz in FMX.Canvas.Mac.pas
iOS: TBitmapCodecQuartz in FMX.Canvas.iOS.pas
Android: TBitmapCodecAndroid in FMX.Canvas.Android.pas
Using {$IFDEF} statements, you might be able to utilize those existing classes inside of your custom codec as needed.

-> http://codeverge.com/embarcadero.del...a-jpeg/1085948
But I looked into some FMX sources and searched for "JPEG" and found a code snippet that works. Here it is:
Delphi-Quellcode:
procedure TForm1.Button1Click(Sender: TObject);
var
  Filter: TBitmapCodec;
  TempBitmap: TBitmap;
begin
  if OpenDialog1.Execute then begin
    TempBitmap := TBitmap.Create(0, 0);
    Filter := DefaultBitmapCodecClass.Create;
    Filter.LoadFromFile(OpenDialog1.FileName, 0, TempBitmap);
    ImageControl1.Bitmap.Assign(TempBitmap);
    Filter.Free;
    TempBitmap.Free;
  end;
end;
And the JPEG appears! - See more at: http://codeverge.com/embarcadero.del....3YuJ46k0.dpuf
  Mit Zitat antworten Zitat
borstenei

Registriert seit: 11. Nov 2011
121 Beiträge
 
#3

AW: Mobile: Wie können dem ImageViewer1 verschiedene .jpgs zugewiesen werden?

  Alt 2. Nov 2015, 16:52
Ich habe das mal eben bei mir nachgestellt:
Delphi-Quellcode:
unit Unit1;

interface

uses
  System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
  FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.Objects,
  FMX.Controls.Presentation, FMX.StdCtrls, FMX.ListBox, FMX.Layouts,
  FMX.TabControl;

type
  TForm1 = class(TForm)
    TabControl1: TTabControl;
    TabItem1: TTabItem;
    TabItem2: TTabItem;
    ListBox1: TListBox;
    ListBoxItem1: TListBoxItem;
    ListBoxItem2: TListBoxItem;
    Button1: TButton;
    Image1: TImage;
    procedure Button1Click(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.fmx}

procedure TForm1.Button1Click(Sender: TObject);
begin
   Image1.Bitmap.LoadFromFile('C:\Users\Frank\test\' + ListBox1.Selected.Text);
   TabControl1.TabIndex := 1;
end;

end.

das funzt bei mir auf Anhieb...warum auch nicht?!
  Mit Zitat antworten Zitat
hoika

Registriert seit: 5. Jul 2006
Ort: Magdeburg
8.277 Beiträge
 
Delphi 10.4 Sydney
 
#4

AW: Mobile: Wie können dem ImageViewer1 verschiedene .jpgs zugewiesen werden?

  Alt 2. Nov 2015, 17:00
Hallo,


Delphi-Quellcode:
// Wozu ist das denn da ?
Image1.Bitmap:=TBitmap.create;
// Was steht in ListBox1.Selected.Text ?
Image1.Bitmap.LoadFromFile('C:\Users\u\Pictures\Goethe\' + ListBox1.Selected.Text);
TabControl1.TabIndex := 1;

Heiko
Heiko
  Mit Zitat antworten Zitat
borstenei

Registriert seit: 11. Nov 2011
121 Beiträge
 
#5

AW: Mobile: Wie können dem ImageViewer1 verschiedene .jpgs zugewiesen werden?

  Alt 2. Nov 2015, 17:05
Hi Sel2012,
so sollte bei Dir der Testaufbau aussehen..
setzt natürlich voraus das Bild1 und Bild2 tatsächlich in dem Ordner befinden...
Angehängte Grafiken
Dateityp: jpg Test2.jpg (51,1 KB, 16x aufgerufen)
Dateityp: jpg Test1.jpg (139,9 KB, 20x aufgerufen)
  Mit Zitat antworten Zitat
Antwort Antwort


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 10:56 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