Recent

Author Topic: show image or svg  (Read 24782 times)

felipemdc

  • Administrator
  • Hero Member
  • *
  • Posts: 3538
Re: show image or svg
« Reply #15 on: May 08, 2012, 02:36:06 pm »
Instead of making a finger X axis scrolling you could just put 2 buttons, for left and right scrolling.

Show the buttons only if Screen.Width < Bitmap.Width

huberte

  • Jr. Member
  • **
  • Posts: 78
Re: show image or svg
« Reply #16 on: May 09, 2012, 02:38:15 am »
OMG, it's hard for me and I short in time to publish the app.

I tried
Quote
begin
  Bitmap := TBitmap.Create;
  try
    // Initializes the Bitmap Size
    Bitmap.Height := Height;
    Bitmap.Width := Width;

    DrawToCanvas(Bitmap.Canvas);

    Canvas.Draw(0, 0, Bitmap);
  finally
    Bitmap.Free;
  end;               

 

Then I tried for several hours to draw an image in canvas with TCanvas.Draw and stretch it with TCanvas.CopyRect with no luck :(

Quote
Show the buttons only if Screen.Width < Bitmap.Width

How do I get the screen size of the android device ?

Quote
OpenDocument API from LCLProc for Android. Then it would open the image in whatever default image viewer, or open a list of choices for the user. I will try doing that this week.

what about this solution ?

felipemdc

  • Administrator
  • Hero Member
  • *
  • Posts: 3538
Re: show image or svg
« Reply #17 on: May 09, 2012, 09:05:58 am »
OMG, it's hard for me and I short in time to publish the app.

I tried ....

You need to show more code. Show your routine DrawToCanvas(Bitmap.Canvas); and also show the declaration of this procedure too. Also, is it really connected to OnPaint in the LFM?

You will probably want to use LoadFromFile instead of DrawToCanvas, for TBitmap it needs to be a .bmp image file. You can use other graphic classes for other formats. See the full list here: http://wiki.lazarus.freepascal.org/Developing%20with%20Graphics#Image_formats

Just change TBitmap for the appropriate class for the format, the rest remains without change.

Quote
How do I get the screen size of the android device ?

Use Screen.Width and Screen.Height

Screen is a global objects of the type TScreen

See: http://lazarus-ccr.sourceforge.net/docs/lcl/forms/tscreen.html

felipemdc

  • Administrator
  • Hero Member
  • *
  • Posts: 3538
Re: show image or svg
« Reply #18 on: May 09, 2012, 12:09:37 pm »
Quote
OpenDocument API from LCLProc for Android. Then it would open the image in whatever default image viewer, or open a list of choices for the user. I will try doing that this week.

what about this solution ?

I started implementing it today, but it crashes right now. It doesn't work yet.

felipemdc

  • Administrator
  • Hero Member
  • *
  • Posts: 3538
Re: show image or svg
« Reply #19 on: May 09, 2012, 02:21:41 pm »
I started implementing it today, but it crashes right now. It doesn't work yet.

Ok, now in revision: 37229 both OpenURL and OpenDocument have initial implementations working.

huberte

  • Jr. Member
  • **
  • Posts: 78
Re: show image or svg
« Reply #20 on: May 10, 2012, 01:31:21 am »
How should I use open document ?

Thks

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: show image or svg
« Reply #21 on: May 10, 2012, 07:30:08 am »
IIRC, I suppose include unit LazUtils and call OpenDocument. At least that's how it works on Windows, Linux...
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

felipemdc

  • Administrator
  • Hero Member
  • *
  • Posts: 3538
Re: show image or svg
« Reply #22 on: May 10, 2012, 08:02:31 am »
IIRC, I suppose include unit LazUtils and call OpenDocument. At least that's how it works on Windows, Linux...

OpenDocument is in LCLIntf, so:

uses LCLIntf;

OpenDocument('/mnt/sdcard/myfile.png');

Every extension needs to be registered, because it needs to be converted to a mime-type. So far I did it for .txt, .png and .jpg

 

TinyPortal © 2005-2018