Page 1 of 2 12 LastLast
Results 1 to 10 of 16

Thread: How to show jpg images in a canvas section

  1. #1
    Senior Member
    Join Date
    Feb 2012
    Location
    Germany, near Jena and Weimar
    Posts
    213

    How to show jpg images in a canvas section

    I'm looking for a solution to the following task:
    I have a very large amount of jpg images (They are sheet music - pages to play from).
    The titles of the images (sheet music - pages of songs) are in a data table with the file names of the images (f.e. 01234.jpg)
    I would like to be able to display these sheets "by click" in a Canvas Formitem "image" or in some other way.

    (I'm playing, since years, with such a program written in VFP. It works by changing the "picture" - property programmatically.
    But now, I would like to have a web app).

    Thanks for ideas in advance!
    Georg

  2. #2
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    6,719
    Blog Entries
    17
    Hi Georg,

    You can load the images into the table into a "Blob" field.

    You then drag the blob field onto a "Form" section or a "Canvas" section.

    As you navigate the records using the ActionBar at the bottom of the page the images will be retrieved and displayed in desktop and web apps.

    Step 1: Add a "Blob" field using ALTER TABLE

    Code:
    alter table yourtable add (yourblobfield blob)
    Step 2: Load the jpg images into the blob field

    Code:
    use yourtable
    replace all yourblobfield with yourimagenamefield // this will load the image into the record
    The advantage of loading the images into the column of a table is that in Web or LAN apps you dont need access to any local filesystem to store and retrieve the images.

    This is only possible because Lianja tables have no 2GB limit. The maximum file size is 2^64.

    Now yourblobfield can be bound to an image in a form or canvas section.

    It can also be used with split grids to display the image, etc. This is the example_navpanel1 App.

    Click image for larger version. 

Name:	Screen Shot 2022-01-19 at 12.35.57 PM.jpg 
Views:	63 
Size:	132.3 KB 
ID:	2735
    Principal developer of Lianja, Recital and other products

    Follow me on:

    Twitter: http://twitter.com/lianjaInc
    Facebook: http://www.facebook.com/LianjaInc
    LinkedIn: http://www.linkedin.com/in/barrymavin

  3. #3
    Senior Member
    Join Date
    Feb 2012
    Location
    Germany, near Jena and Weimar
    Posts
    213
    Thank you, Barry!

    Good idea!
    But there I see a few "problems" for me:
    - I cannot edit the pictures (jpg) in the blob by a photo editor
    - Since a "title" can consist of several jpg files I need a child table for the blobs
    - I need to write a program to load the thousends of jpg files into the blobs
    - and another one to upload new titles to the web app
    - Maybe the child table would be a "big monster", not very good for data saving?

    Is there this possibility:
    Could I use the "background image" attribute for that purpose?

    Georg

  4. #4
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    6,719
    Blog Entries
    17
    Hi Georg

    Forget background image. That makes no sense to me.

    This function is built into Lianja as I explained earlier.

    You can update images through the UI or in a server side procedure. thatís not difficult. So thereís nothing stopping you extracting, editing and updating the images.

    The table size does not matter. Images are stored in the dbt file and space is reused when records are deleted or updated.
    Principal developer of Lianja, Recital and other products

    Follow me on:

    Twitter: http://twitter.com/lianjaInc
    Facebook: http://www.facebook.com/LianjaInc
    LinkedIn: http://www.linkedin.com/in/barrymavin

  5. #5
    Lianja MVP
    Join Date
    Dec 2012
    Location
    Croatia, Zagreb
    Posts
    1,129
    Hi Georg,

    There was a post long time ago about the decision: to store all images in a table or to point a web url at the root folder:
    https://www.lianja.com/community/sho...es-with-Lianja

  6. #6
    Senior Member
    Join Date
    Feb 2012
    Location
    Germany, near Jena and Weimar
    Posts
    213
    yes, I saw that storing the images in a table is reasonable
    thanks
    Georg

  7. #7
    Senior Member
    Join Date
    Feb 2012
    Location
    Germany, near Jena and Weimar
    Posts
    213
    1)
    I can easily insert images into a table of blobs using
    "replace blobfield with pict_file",
    but only via the command workspace.
    The same fails when I do the exact same thing in the app in a *.prg file.

    2)
    The names of the "pict_files" are in a memo field, each "pict_file" is in one line.
    In the command workspace I can use the functions
    "memlines(memofield)" and "mline(memofield,lineno)".
    The same does not work via a prg script in my app:
    It shows that the memo is empty (empty() or memlines() = 0).

    I've tried everything with my VFP experience.
    There are no Lianja errors, but the memo is shown as empty.
    However, the memo is displayed correctly in a canvas section in an edit box.

    Do you have any idea?
    Georg

  8. #8
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    6,719
    Blog Entries
    17
    Hi Georg

    Check that the image path is accessible using the file() function in your prg.

    If it works from the command line it will work in your prg if there is an active record I.e not eof()
    Principal developer of Lianja, Recital and other products

    Follow me on:

    Twitter: http://twitter.com/lianjaInc
    Facebook: http://www.facebook.com/LianjaInc
    LinkedIn: http://www.linkedin.com/in/barrymavin

  9. #9
    Senior Member
    Join Date
    Feb 2012
    Location
    Germany, near Jena and Weimar
    Posts
    213
    Hi Barry,
    yes, I checked the pict pad by file().
    The right record:
    I read a few fields like the ID from the main table for the child table and the memo field where is the pict file name too. Sorry I get the message the memo field is empty as I wrote...

    Following steps if I would have the file name out of the memo of the main table:
    Child table:
    append blank
    replace the ID and the other fields and
    replace the blob field too with the pict.

    ----
    var retval = Lianja.evaluate("fuell_blob('" + satznr + "')");
    ....
    fuell_blob.prg parameter is the record number of the main table with the info for the child table.

    fuell_blob.prg code:
    ....
    parameters satznr

    satznr = val(satznr) // OK

    cr = chr(13)

    // main table
    select inhalt_gotteslob
    goto satznr

    dateien1 = alltrim(html_toplaintext(inhalt_gotteslob.dateien, .T.))
    // dateien1 = inhalt_gotteslob.dateien

    zeilen = memlines(dateien1) // NOT OK, zeilen is 0

    inhalt = "Tabelle: " + alias()+ cr + ;
    "ID: " + allt( str(ID)) + cr + ;
    "Lied: " + allt(gesang) + cr + ;
    "Nr: " + Nummer_c + cr + ;
    "Anz.jpg: " + str(zeilen)
    // lines 1,2,3,4 (info from the main table OK, line 5 wrong

    if empty(dateien1)
    messagebox("Memo leer: " + cr + inhalt) // Because memo empty RETURN
    return
    else
    messagebox("Memo ok: " + cr + inhalt)
    endif

    for seite1 = 1 to zeilen
    datei = mline(dateien,seite1)

    datei = "Z:\Gotteslob_alles\" + alltrim(inhalt_gotteslob.setname) + "\" + allt(datei)

    if !file(datei)
    messagebox("Datei nicht da: " + datei)
    loop
    endif

    // use bilder_lieder
    select bilder_lieder
    append blank

    replace bilder_lieder.ID with inhalt_gotteslob.ID
    replace bilder_lieder.Seite with VAL(seite1)
    replace bilder_lieder.gesang with inhalt_gotteslob.gesang

    REPLACE BILD WITH datei

    endfor

    messagebox("End of fuell_blob.prg")

    // back to main table
    select inhalt_gotteslob

    return
    Last edited by gcjm; 2022-01-27 at 19:57.

  10. #10
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    6,719
    Blog Entries
    17
    Hi Georg,

    Replacing a blob field with a varchar won't work. It needs to be a char field.

    So the solution is to use the ETOS() function.

    replace blobname with alltrim( etos(varcharname) )
    Principal developer of Lianja, Recital and other products

    Follow me on:

    Twitter: http://twitter.com/lianjaInc
    Facebook: http://www.facebook.com/LianjaInc
    LinkedIn: http://www.linkedin.com/in/barrymavin

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Journey into the Cloud
Join us