get hBitmap from Image

get hBitmap from Image

Postby Jimmy » Thu Oct 20, 2022 5:33 am

hi,

instead of ILADDICON()*** i like to use ILADD()*** for Imagelist
*** in c:\fwh\source\winapi\imagelis.c

but i must get hBitmap from File
Code: Select all  Expand view  RUN
hBitmap = ( HBITMAP ) LoadImage( NULL, lpImageName, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_DEFAULTCOLOR );

is there any Fivewin Function or do i have to write my own HB_FUNC() :?:
who can help please
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1732
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: get hBitmap from Image

Postby Natter » Thu Oct 20, 2022 6:29 am

Hi, Jimmy !

FW_ReadImage(NIL, xPt) //xPt - path+file

or so

hBmp:=oWnd:ReadImage(xPt)[1]
Natter
 
Posts: 1224
Joined: Mon May 14, 2007 9:49 am

Re: get hBitmap from Image

Postby Jimmy » Thu Oct 20, 2022 7:37 am

hi,
Natter wrote:hBmp:=oWnd:ReadImage(xPt)[1]

YES thx,
now i can load IMAGE into Imagelist :D

after > 100 Image it begin to fail ... RAM is going to Limit (32 Bit OS)

---

it take a long Time to load about 800 Image from some Kb up 2.5 MB (!)
to reduce RAM i need to "resize" Image to 256 x 256, how under FiveWin :?: ( have hBitmap )

when have use ::oWnd:ReadImage() how to "destroy" Image :?:

p.s. "where" to read about "ReadImage" as i did not found in c:\fwh\manual\
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1732
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: get hBitmap from Image

Postby Natter » Thu Oct 20, 2022 8:24 am

I have to save a lot of photos (jpg) to the server. From 100 to 500 pieces daily. Each weighs 5-6 Mg. There are not enough resources to store such volumes. :D I have a very small utility (with a command line) with which I compress each file (without loss of quality) by about 3-4 times. Maybe go this way ?
You can make miniatures.

I don 't know about "destroy Image "

The FW_readImage() function is in c:\fwh\Source\Function\imgtxtio.prg
Natter
 
Posts: 1224
Joined: Mon May 14, 2007 9:49 am

Re: get hBitmap from Image

Postby nageswaragunupudi » Thu Oct 20, 2022 4:13 pm

FW_ReadImage( ;
[oWnd / hDC ] ; //or NIL
uImage, ;
[aSize], ; // { w, h } for resizing
[lGDIP] ) // Use GDI+ or not. Default .F.
--> aImage.

uImage:
Can be any file name, resource name, image buffer, hBitmap, hIcon, aShape Array, Image URL on the Web, Symbol

aImage {
hBitmap (GDI ) or pImage( GDI+ ),
hPalette,
width,
height,
lHasAlphaChannel,
cSourceName,
IsFromResource,
"BITMAP/PIMAGE", // If GDI+, "PIMAGE"
nZeroZeroClr,
ImageType (BMP/JPG/PNG, etc)
}

Destroy:
PalBmpFree( aImage )
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10646
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: get hBitmap from Image

Postby Jimmy » Fri Oct 21, 2022 5:16 am

hi,

i´m using
Code: Select all  Expand view  RUN
  aBitmaps := ::oWnd:ReadImage( ::cPath + cFile )

not FW_ReadImage() "direct"

---

i have not found any Information about FW_ReadImage or ReadImage in Help File
thx for post Information

---

i have test a lot more Image and all seems to "work" , only "one" Image crash hole App

but i have another Question

when using 2nd Parameter Image (re)Size of o:ReadImage()
Code: Select all  Expand view  RUN
  aBitmaps := ::oWnd:ReadImage( ::cPath + cFile,{256,256} )

all 3 does "work" but 3rd Bitmap are not show correct ... perhaps Imagelist ...
when not use 2nd Parameter all 3 will show Image but only upper left 256 x 256

any Idea :idea:
{2131038683, 0, 256, 205, .T., c:\fwh\0\Listview\TGrid_Style_Icon.png, .F., BITMAP, NIL, PNG}
{-200993784, 0, 256, 205, .T., c:\fwh\0\Listview\TGrid_Style_Report.png, .F., BITMAP, NIL, PNG}
{805638570, 0, 58, 256, .T., c:\fwh\0\Listview\TGrid_Style_Thumbs.png, .F., BITMAP, NIL, PNG}


p.s. Image are from this Thread so you can download them
https://forums.fivetechsupport.com/viewtopic.php?f=3&t=42331
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1732
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: get hBitmap from Image

Postby nageswaragunupudi » Fri Oct 21, 2022 7:48 am

only "one" Image crash hole App

Can you please send that image file?
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10646
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: get hBitmap from Image

Postby nageswaragunupudi » Fri Oct 21, 2022 7:53 am

i´m using
Code:
aBitmaps := ::oWnd:ReadImage( ::cPath + cFile )

not FW_ReadImage() "direct"


Both are same.

Had you spent a little time to open window.prg, you would have noticed:
Code: Select all  Expand view  RUN
METHOD ReadImage( uSource, aSize, lGdipImage ) INLINE FW_ReadImage( Self, uSource, aSize, lGDIPImage )
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10646
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: get hBitmap from Image

Postby Enrico Maria Giordano » Fri Oct 21, 2022 8:02 am

Jimmy wrote:hi,

i´m using
Code: Select all  Expand view  RUN
  aBitmaps := ::oWnd:ReadImage( ::cPath + cFile )

not FW_ReadImage() "direct"


This is working fine here too:

#include "Fivewin.ch"


Code: Select all  Expand view  RUN
FUNCTION MAIN()

    LOCAL oWnd

    DEFINE WINDOW oWnd

    ACTIVATE WINDOW oWnd;
             ON INIT MsgInfo( oWnd:ReadImage( "DSL_Verfügbarkeit2.JPG" )[ 1 ] )

    RETURN NIL
User avatar
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: get hBitmap from Image

Postby Jimmy » Fri Oct 21, 2022 9:22 pm

hi Enrico,

you are right that it work with your CODE.

i do get Filename from DIRECTORY() and it have a German "Umlaut ü"

that´s why i ask for UNICODE, ANSI or OEM from DIRECTORY() to use with ShellExecute()
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1732
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: get hBitmap from Image

Postby Enrico Maria Giordano » Fri Oct 21, 2022 9:55 pm

Try setting the correct codepage. Have a look at this thread for some ideas:

https://forums.fivetechsupport.com/viewtopic.php?t=40243
User avatar
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: get hBitmap from Image

Postby Jimmy » Sat Oct 22, 2022 12:09 am

hi,

i try to REQUEST all Codepage and Language
Code: Select all  Expand view  RUN
#include "FiveWin.ch"

REQUEST HB_LANG_ES
REQUEST HB_LANG_EN
REQUEST HB_LANG_FR
REQUEST HB_LANG_PT
REQUEST HB_LANG_DEWIN
REQUEST HB_LANG_RUWIN
REQUEST HB_LANG_IT
REQUEST HB_LANG_PLWIN
REQUEST HB_LANG_EU
REQUEST HB_LANG_HR852
REQUEST HB_LANG_SLWIN
REQUEST HB_LANG_CSWIN

REQUEST HB_CODEPAGE_BG866
REQUEST HB_CODEPAGE_BGISO
REQUEST HB_CODEPAGE_BGMIK
REQUEST HB_CODEPAGE_BGWIN
REQUEST HB_CODEPAGE_CS852
REQUEST HB_CODEPAGE_CS852C                                            // not in Grid
REQUEST HB_CODEPAGE_CSISO
REQUEST HB_CODEPAGE_CSKAMC                                            // not in Grid
REQUEST HB_CODEPAGE_CSWIN
REQUEST HB_CODEPAGE_DE850
REQUEST HB_CODEPAGE_DE850M                                            // not in Grid
REQUEST HB_CODEPAGE_DEISO                                             // not in Grid
REQUEST HB_CODEPAGE_DEWIN
REQUEST HB_CODEPAGE_DK865                                             // not in Grid
REQUEST HB_CODEPAGE_EL437                                             // not in Grid
REQUEST HB_CODEPAGE_EL737
REQUEST HB_CODEPAGE_ELISO                                             // not in Grid
REQUEST HB_CODEPAGE_ELWIN
REQUEST HB_CODEPAGE_EN
REQUEST HB_CODEPAGE_ES850
REQUEST HB_CODEPAGE_ES850C                                            // not in Grid
REQUEST HB_CODEPAGE_ES850M                                            // not in Grid
REQUEST HB_CODEPAGE_ESISO                                             // not in Grid
REQUEST HB_CODEPAGE_ESMWIN
REQUEST HB_CODEPAGE_ESWIN
REQUEST HB_CODEPAGE_FI850                                             // not in Grid
REQUEST HB_CODEPAGE_FR850
REQUEST HB_CODEPAGE_FR850C                                            // not in Grid
REQUEST HB_CODEPAGE_FR850M                                            // not in Grid
REQUEST HB_CODEPAGE_FRISO                                             // not in Grid
REQUEST HB_CODEPAGE_FRWIN                                             // not in Grid
REQUEST HB_CODEPAGE_HE862                                             // not in Grid
REQUEST HB_CODEPAGE_HEWIN                                             // not in Grid
REQUEST HB_CODEPAGE_HR646
REQUEST HB_CODEPAGE_HR852
REQUEST HB_CODEPAGE_HRISO                                             // not in Grid
REQUEST HB_CODEPAGE_HRWIN
REQUEST HB_CODEPAGE_HU852
REQUEST HB_CODEPAGE_HU852C
REQUEST HB_CODEPAGE_HUISO
REQUEST HB_CODEPAGE_HUWIN
REQUEST HB_CODEPAGE_IS850                                             // not in Grid
REQUEST HB_CODEPAGE_IS861                                             // not in Grid
REQUEST HB_CODEPAGE_IT437
REQUEST HB_CODEPAGE_IT850
REQUEST HB_CODEPAGE_IT850M                                            // not in Grid
REQUEST HB_CODEPAGE_ITISB
REQUEST HB_CODEPAGE_ITISO
REQUEST HB_CODEPAGE_ITWIN                                             // not in Grid
REQUEST HB_CODEPAGE_LT775                                             // not in Grid
REQUEST HB_CODEPAGE_LTWIN
REQUEST HB_CODEPAGE_NL850                                             // not in Grid
REQUEST HB_CODEPAGE_NL850M                                            // not in Grid
REQUEST HB_CODEPAGE_NO865                                             // not in Grid
REQUEST HB_CODEPAGE_PL852
REQUEST HB_CODEPAGE_PLISO
REQUEST HB_CODEPAGE_PLMAZ
REQUEST HB_CODEPAGE_PLWIN
REQUEST HB_CODEPAGE_PT850
REQUEST HB_CODEPAGE_PT860                                             // not in Grid
REQUEST HB_CODEPAGE_PTISO
REQUEST HB_CODEPAGE_RO852                                             // not in Grid
REQUEST HB_CODEPAGE_ROISO                                             // not in Grid
REQUEST HB_CODEPAGE_ROWIN                                             // not in Grid
REQUEST HB_CODEPAGE_RU1251
REQUEST HB_CODEPAGE_RU866
REQUEST HB_CODEPAGE_RUISO                                             // not in Grid
REQUEST HB_CODEPAGE_RUKOI8
REQUEST HB_CODEPAGE_SK852
REQUEST HB_CODEPAGE_SK852C                                            // not in Grid
REQUEST HB_CODEPAGE_SKISO
REQUEST HB_CODEPAGE_SKKAMC                                            // not in Grid
REQUEST HB_CODEPAGE_SKWIN
REQUEST HB_CODEPAGE_SL646                                             // not in Grid
REQUEST HB_CODEPAGE_SL852
REQUEST HB_CODEPAGE_SLISO
REQUEST HB_CODEPAGE_SLWIN
REQUEST HB_CODEPAGE_SR646                                             // not in Grid
REQUEST HB_CODEPAGE_SR646C                                            // not in Grid
REQUEST HB_CODEPAGE_SRWIN
REQUEST HB_CODEPAGE_SV437C
REQUEST HB_CODEPAGE_SV850
REQUEST HB_CODEPAGE_SV850M                                            // not in Grid
REQUEST HB_CODEPAGE_SVISO
REQUEST HB_CODEPAGE_SVWIN
REQUEST HB_CODEPAGE_TR857
REQUEST HB_CODEPAGE_TRISO                                             // not in Grid
REQUEST HB_CODEPAGE_TRWIN
REQUEST HB_CODEPAGE_UA1125                                            // not in Grid
REQUEST HB_CODEPAGE_UA1251
REQUEST HB_CODEPAGE_UA866
REQUEST HB_CODEPAGE_UAKOI8
REQUEST HB_CODEPAGE_UTF16LE                                           // not in Grid
REQUEST HB_CODEPAGE_UTF8
REQUEST HB_CODEPAGE_UTF8EX

FUNCTION MAIN()
LOCAL oWnd
LOCAL aDir
LOCAL cFile
LOCAL cLanguage := "DEWIN"
LOCAL cCodepage := "DEWIN"

   FW_SetUnicode( .t. )
   hb_LangSelect( cLanguage )
   hb_CDPSELECT( cCodepage )
   HB_SETCODEPAGE( cCodepage )

   aDir := DIRECTORY( "DSL*.*" )
   msginfo(hb_valToExp(aDir))
   cFile := aDir[1][1]
   msginfo(cFile)

      DEFINE   WINDOW oWnd
      ACTIVATE   WINDOW oWnd;
         ON INIT  MsgInfo( oWnd:ReadImage  ( cFile) )

RETURN NIL

in 1st and 2nd MsgInfo() i can see "Umlaut ü"
but last MsgInfo() say "ARRAY" and show a EMPTY Windows ... :(

Question : which Codepage and Language Setting are need for
1.) DIRECTORY()
2.) oWnd:ReadImage()

p.s. it does not work with every Image, just rename it and include German "Umlaut" like "ü", "ä" or "ö"
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1732
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: get hBitmap from Image

Postby Jimmy » Sat Oct 22, 2022 4:34 am

hi,

i have now try to include hb_CDPSELECT() so i can load File with "Umlaut ü"
Code: Select all  Expand view  RUN
LOCAL cLangCode := "DE"
LOCAL cCodepage := "DEWIN"
    hb_LangSelect( cLangCode )
    hb_CDPSELECT(  cCodepage )

but than my Imagelist produce wrong "System-Icon" ...

this is without hb_CDPSELECT()
Image
this with hb_CDPSELECT()
Image
you can see "wrong" Icon which are placed to wrong Filename

what i´m doing wrong :?:
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1732
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: get hBitmap from Image

Postby Enrico Maria Giordano » Sat Oct 22, 2022 8:11 am

I don't understand. Can I have a complete sample of the problem?
User avatar
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: get hBitmap from Image

Postby Jimmy » Sat Oct 22, 2022 8:57 am

hi Enrico,
Enrico Maria Giordano wrote:I don't understand. Can I have a complete sample of the problem?

it is the Demo for CLASS TGrid() on which i´m working

i got it almost working but not finish to release it yet

i prefer to work in 32 Bit Environment while my favorite Editor is only 16 Bit ...
i have to use NPP++ (Notepad ++) under 64 Bit but i can not do what my ETP Editor can do

so i do only "small" work like edit HB_FUNC() and change Parameter Type to use with 64 Bit
i think next Week i can release CLASS TGrid() Demo Source when have check 64 Bit Environment

p.s. i got Solution for "wrong" Icon (Size)
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1732
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 61 guests