papyvore
Messages postés223Date d'inscriptionsamedi 15 novembre 2003StatutMembreDernière intervention16 décembre 2021
-
Modifié le 16 déc. 2021 à 09:17
papyvore
Messages postés223Date d'inscriptionsamedi 15 novembre 2003StatutMembreDernière intervention16 décembre 2021
-
16 déc. 2021 à 17:24
Bonjour,
j'ai une procedure comme celle-ci
{$IFDEF ANDROID}
if TPlatformServices.Current.SupportsPlatformService(IFMXClipboardService, Svc)
then
begin
Value := Svc.GetClipboard;
if not Value.IsEmpty then
begin
{
//teste passage, ok value n'est pas vide
s := 'InsertPictureFromClipBoard not Value.IsEmpty';
TDialogservice.MessageDialog(s, TMsgDlgType.mtConfirmation,
[TMsgDlgBtn.mbYes, TMsgDlgBtn.mbNo], TMsgDlgBtn.mbYes, 0,
procedure(const AResult: TModalResult)
begin
Reply := AResult;
end);
if Reply <> mrYes then
}
if Value.IsType<TBitmapSurface> then
try
Bitmap := TBitmap.Create;
try
Bitmap.Assign(Value.AsType<FMX.Surfaces.TBitmapSurface>);
Image1.Bitmap := Bitmap;
finally
Bitmap.Free;
end;
finally
Value.AsType<FMX.Surfaces.TBitmapSurface>.Free;
end;
end;
qui marche sous fmx windows mais pas sous android. la copie vers image1 ne se fait pas.
il semblerait que le problème soit ici
if Value.IsType<TBitmapSurface>
et je sais pas par quoi le remplacer. le type serait différent sous android que sous windows???
si une bonne âme qui passe par là a une idée je suis preneur.:)
...
Windows, macOS and iOS platforms provide copy/paste of both text and images. The Android clipboard does not support images. To allow users to copy and paste images between your own Android applications, you can use a custom format instead.
...
procedure TCopyPasteDemo.CopyButtonClick(Sender: TObject);
var
Svc: IFMXClipboardService;
Image: TBitmap;
begin
if TPlatformServices.Current.SupportsPlatformService(IFMXClipboardService, Svc) then
if TextRadioButton.IsChecked then
Svc.SetClipboard(Edit1.Text)
else
begin
Image := TextBorder.MakeScreenshot;
try
Svc.SetClipboard(Image);
finally
Image.Free;
end;
end;
end;
procedure TCopyPasteDemo.PasteButtonClick(Sender: TObject);
var
Svc: IFMXClipboardService;
Value: TValue;
Bitmap: TBitmap;
begin
if TPlatformServices.Current.SupportsPlatformService(IFMXClipboardService, Svc) then
begin
Value := Svc.GetClipboard;
if not Value.IsEmpty then
begin
if Value.IsType<string> then
begin
PasteLabel.Text := Value.ToString;
PasteImage.Bitmap := nil;
end
else if Value.IsType<TBitmapSurface> then
try
PasteLabel.Text := string.Empty;
Bitmap := TBitmap.Create;
try
Bitmap.Assign(Value.AsType<TBitmapSurface>);
PasteImage.Bitmap := Bitmap;
finally
Bitmap.Free;
end;
finally
Value.AsType<TBitmapSurface>.Free;
end;
end;
end;
end;
Cordialement,
papyvore
Messages postés223Date d'inscriptionsamedi 15 novembre 2003StatutMembreDernière intervention16 décembre 202115 16 déc. 2021 à 17:24
salut merci de cette réponse
j'ai vu cet exemple. Sur tablette dans l'onglet paste pour le texte ok, mais pour image je reçois (TBitmap@C9....)
je suppose l'adresse .C'est la que je coince je ne sais pas quel format personnalisé mettre à la place.
Ou plutôt je ne sais personnaliser le format.
16 déc. 2021 à 17:24
j'ai vu cet exemple. Sur tablette dans l'onglet paste pour le texte ok, mais pour image je reçois (TBitmap@C9....)
je suppose l'adresse .C'est la que je coince je ne sais pas quel format personnalisé mettre à la place.
Ou plutôt je ne sais personnaliser le format.