Menu

#51 How tu use image in container ?

v1.0_(example)
closed
nobody
None
1
2020-11-30
2020-08-15
No

Hi,

I have tried to use bincnt, and it seems nice to gropu icons and images in one file.

But how to keep these images or icons in an hwgui program ?

Thanks
A+

Discussion

  • Aupeix Alain

    Aupeix Alain - 2020-08-15

    Sorry for the noise, I have found the answer in HwGui documantation ...

    A+

     
  • Aupeix Alain

    Aupeix Alain - 2020-08-15

    Hum, trying that :
    ~~~hwg_SetResContainer( cpPath + "/hwmake.bin" )
    oBitmap := HBitmap():AddResource( "open" )
    @ htab+(nbut*32), 3 OWNERBUTTON OF oToolbar ;
    ON CLICK {||Container()} ;
    SIZE 28,24 FLAT ;
    BITMAP "container" FROM RESOURCE TRANSPARENT COLOR ;
    hwg_ColorC2N("#DCDAD5") COORDINATES 0,4,0,0 ;
    TOOLTIP _("Gérer un container")~~~

    No error, but image isn't displayed

    Content oy hwmake.bin:

    container png
    hwmake  png
    

    Where do I fail ?

    A+

     
  • Wilfried Brunken

    Hello Alain,
    see HWGUI Docu:

    doc/hwgdoc_commands.html

    4.3.27. @ <x>,<y> BITMAP
    ...
    Supported image formats: bmp, jpg </y></x>

    For png it is necessary, to use the IMAGE term, but you must link the
    FreeImage library to your application.

    Please try the following:
    - Convert your png's to *.bmp
    For example with Windows utility "Paint".
    - Replace the ressources with the Binary container manager.
    - Start your app again.

    I hope, this helps you.

    Otherwise i need a sample to retrace your problem.

    With regards,
    MNI TNX, 73 es 55 de
    DF7BE, Wilfried

     
  • Aupeix Alain

    Aupeix Alain - 2020-08-18

    Thanks, I saw it;
    I add -lhbmagic, but it doesn't work

    cImageDir := cppath+"/image/"
    // Ouverture du container
    hwg_SetResContainer( cImageDir + "hwmake.bin" )
    
    //oIcon := HIcon():AddFile( cImageDir+"geneweb.png" )
    oIcon := HIcon():AddResource( "geneweb" )
    ...
    oBitmap := HBitmap():AddResource("open")
    @ htab+(nbut*32), 3 OWNERBUTTON oFileOpen OF oToolbar ;
       ON CLICK {||FileOpen()} ;
       SIZE 28,24 FLAT ;
       BITMAP oBitmap TRANSPARENT COLOR hwg_ColorC2N("#DCDAD5") COORDINATES 0,4,0,0 ;
       TOOLTIP "Ouvrir un fichier"
    nbut+=1
    
    @ htab+(nbut*32),3 OWNERBUTTON oReadReg OF oToolbar ;
       ON CLICK {||ReadReg()} ;
       SIZE 28,24 FLAT ;
       BITMAP cImageDir+"lire.png" TRANSPARENT COLOR hwg_ColorC2N("#DCDAD5") COORDINATES 0,4,0,0 ;
       TOOLTIP "Lire un registre"
    nbut+=1
    

    As you can see with the two screen:
    Before using the container, it works for icon and buttons using png image
    Using the container, it doesn't work anymore.
    It seems that BITMAP parameters wants a filename, and container gives the content of the file ...
    When using BITMAT from RESOURCE, RESOURCE gives the fileanme (and path) of the image, and that's why it works

    Am-I wrong ?

    A+

     
  • Wilfried Brunken

    Hello Alain,
    I needed some time to create a full sample to
    retrace the case (r2869).
    The new sample works best with WinAPI,
    but the PNG is not visible/supported in the OWNWERBUTTON
    (i documentated this a few days ago).

    There is really a bug in the GTK implementation,
    please be patient, i need some time for analysis.

    If you have some ideas in the meantime, please post them.
    To be continued !

    With regards,
    MNI TNX, 73 es 55 de
    DF7BE, Wilfried

     
  • Aupeix Alain

    Aupeix Alain - 2020-08-21

    Hi Wilfried,
    I have replaced the png file by a jpg file, and it doesn't work too.
    So it seems evident that the problem isn't due to png, but the use of a container.

    As I suppose the the command

    oBitmap := HBitmap():AddResource("open")
    

    returns athe contant of the file, the parameter is now a binary, not a path, so I suppose that ownerbutton is waiting for a path, not a binary ...

    If so, it could perhaps be possible to test the content of the param to see if it's a binary, and perhaps its type in ownerbutton source ?

    For Windows test, have you test with bincnt or rc ?
    If you have use bincnt, the only location where it fails is ownerbutton or gtk ...

    Thanks
    A+

     
  • Aupeix Alain

    Aupeix Alain - 2020-08-21

    other test:

    // Ouverture du container
    test=hwg_SetResContainer( cImageDir + "hwmake.bin" )
    qout("*************")
    qout( cImageDir + "hwmake.bin" )
    qout(test)
    qout("*************")
    oBitmap := HBitmap():AddResource("open")
    //oBitmap := hwg_BmpFromRes("open")
    qout(oBitmap)
    

    returns :

    *************
    /opt/GeneTools/image/hwmake.bin
    .F.
    *************
    NIL
    

    Tests made with with AddResource and BmpFromRes ... and a jpg image

    It seems that SetResContainer is the reason of the problem ...

    A+

     
  • Wilfried Brunken

    Hello Alain,
    MNI TNX for your last posts.
    I give you an intermediate status report:
    The problem is, that the binary container
    stores and reads the contents with MEMOWRITE and
    MEMOREAD.
    For displaying an image GTK has it's own format
    "GDK pixbuffer", there seems to be a conflict.

    I have some ideas to solve this and must read a
    lot of instructions in the GTK reference.

    Please be patient, i hope that i can deliver a
    fix in the next few days.

    With regards,
    MNI TNX, 73 es 55 de
    DF7BE, Wilfried

     
  • Aupeix Alain

    Aupeix Alain - 2020-08-22

    thanks

     
  • Wilfried Brunken

    Hello Alain,
    after a full sunday's work i fixed
    the problem.

    The first problem was solved in
    source/gtk/drawwidg.prg:
    ::handle := hwg_Openimage( cVal ) && 2nd parameter not .T. !
    First trying to read from file,
    in case cVal is PIXBUFF data, the above call fails and the
    cVal was now interpreted as contents
    of an image. It is written into
    a temporary file and now the image
    was loaded succesfully from file
    with function hwg_Openimage().

    hwg_Openimage( name , ltype )
    ltype : .F. : from image file
    .T. : from GDK pixbuffer
    returns handle to pixbuffer

    The second problem is the
    TOOLBOX command.
    Substituted by the PANEL command,
    (Oh what a wonder !) the
    ownerbuttons are now visible !
    (I think, that is OK for you)
    I found this sample in the tutorial.

    With call of function
    hwg_CreateTempfileName()
    the creation of names for
    temporary files is multi platform ready.
    So the sample also works on WinAPI and
    the GTK cross development environment on Windows 10.

    On LINUX, the formats .bmp, .jpg and .png are supported.
    on Windows GTK only
    .bmp.

    I appended a snapshot from my LinuxMINT system,
    the icon appears here in the task bar.
    and is also visible (ok.ico).

    If you do not want to get the complete code snapshot,
    change or add files from the commits
    r2872 and r2871.

    Use the sample program
    /trunk/hwgui/samples/gtk_samples/bincnts.prg
    for check.

    Please give feedback, if Alexander Kresin can close the ticket.
    Thank you for your support. It is a good idea for me,
    to invent the binary container in my application "CLLOG".

    With regards
    MNI TNX, 73 es 55 de
    DF7BE, Wilfried

     
  • Wilfried Brunken

    Here the screenshot.

     
  • Aupeix Alain

    Aupeix Alain - 2020-08-24

    Hi Wilfried,
    Thanks for your efforts, but it doesn't solves my problem

    Here are the lines about this problem:

    hwg_SetResContainer( cpPath + "/hwmake.bin" )
    ...
    oBitmap := HBitmap():AddResource( "container" )
       @ htab+(nbut*32), 3 OWNERBUTTON OF oToolbar ;
          ON CLICK {||Container()} ;
          SIZE 28,24 FLAT ;
          BITMAP oBitmap TRANSPARENT COLOR hwg_ColorC2N("#DCDAD5") COORDINATES 0,4,0,0 ;
          TOOLTIP _("Gérer un container")
    

    Do I made some error ?

    Thanks
    A+

     
  • Aupeix Alain

    Aupeix Alain - 2020-08-24

    Hi,
    Your sample works, so I tried to see what was the difference

    Here are two screenshots which can perhaps explain why ...
    Concerning theresolution, I don't think it's the problem, but hexdump shows differences sBIT (my png) and sRGB (yours)
    I put my png to let you try on your system ...

    Thanks
    A+

     

    Last edit: Aupeix Alain 2020-08-24
  • Aupeix Alain

    Aupeix Alain - 2020-08-24

    hexdump

     
  • Aupeix Alain

    Aupeix Alain - 2020-08-24

    my png

     
  • Wilfried Brunken

    Hello Alain,
    i have done the following steps to retrace your problem
    (LinuxMINT Cinnamon):
    I added "container.png" with the Manager on this LINUX system
    and this image is also visible.
    The container with the first images was created on Windows.
    Result see commit r2874.
    Appended my screenshot.
    The image is OK.
    Tomorow i can check it against Ubuntu 16.

    I am pleased looking to the screenshot of your utility.
    I think, it could be useful for other LINUX friends using Harbour + HWGUI.
    Do you decide to release it as Open Source ?

    With regards
    MNI TNX, 73 es 55 de
    DF7BE, Wilfried

     
  • Itamar M. Lins Jr.

    Hi!
    Here works. But file astro.png with bug.
    Open file and add hwgui.png with sucess! Via /utils/bincnt

    Regards,
    Itamar M. Lins Jr.

     

    Last edit: Itamar M. Lins Jr. 2020-08-24
  • Aupeix Alain

    Aupeix Alain - 2020-08-25

    Hi Itmar,
    What is the linux build and the version you use ?
    For me with Xubuntu 16.04, it fails ...

    Wilfried,
    concerning hwmake linux, I have some little problems to solve, a feature to do, and I have to make the doc ...
    Features are :
    Manage hwmake
    . Manage harbour and hwgui folders
    . Manage harbour, contrib and hwgui libraries
    . Set needed tools to use hwmake functionalities
    . Manage (Create, update, set) languages files for hwmake (po and hbl files), for now, french and english.
    . Acces to the source of hwmake, to the hwmake todo file
    . Acces to harbour, hwgui, clipper documentations (local and online)
    Manage the projects (open, create and save)
    Manage the debugger
    Manage the warnings
    Build the projects
    Run the project
    View log files
    Open the terminal or filebrowser in the source folder (of the project)
    * [ToDo] Manage (Create, update, set) languages files for projects (po and hbl files)

    It has been made starting from the Windows version. For a few thing I have created functions to works like windows functions work (inifile functions, ...)
    I sent it to Alexander, but he seems notinterested to add it to utils. I suppose he was too busy, and i find, this tool a little old and not too much interesting ...
    For now, I have the original version in my own folders, but I have also locate in in hwgui source folder (utils/hwmake/linux/hwmake)

    When it will more achieved, I'll send it ... and obviously it will be under the same license than hwgui.

    Thanks
    A+

     

    Last edit: Aupeix Alain 2020-08-25
  • Wilfried Brunken

    Hello Itamar,
    the image astro.png is ok on my system an in svn repo. It has 24915 Bytes.
    I added this to the binary container and modified the sample
    for display it with the BITMAP command.
    The result is in the appended screenshot.
    Committed with r2875.

    Hello Alain,
    TNX fer offer to publish the hwmake-linux as Open Source.

    If the app is achived, there are 3 alternatives:

    1.) Ask Alexander for giving permission as a developer of HWGUI.

    2.) Post the first issue via the ticket #51 and i will test and commit it.

    3.) The best case: You have an account on sourceforge.net and
    so you can create an own project and you are the project admininstrator.
    First it is necessary to create the basic directories trunk, branches
    and tags.
    For support you can give me permission to checkin into Subversion repository,
    if you want.

    I use the svn command to manage the source code.

    If your choice is 3, i will add a link in the HWGUI documents.

    With regards,
    MNI TNX, 73 es 55 de
    DF7BE, Wilfried

     
  • Itamar M. Lins Jr.

    Hi! now all OK.
    Here is Ubuntu_64Bit version 20.04.1 Kubuntu. KDE

    Best regards,
    Itamar M. Lins Jr.

     

    Last edit: Itamar M. Lins Jr. 2020-08-25
  • Aupeix Alain

    Aupeix Alain - 2020-08-28

    Hi,

    now it works :)

    thanks
    A+

     

    Last edit: Aupeix Alain 2020-08-28
  • Maurizio la Cecilia

    • status: open --> closed
     

Log in to post a comment.