bmpfromico

Re: bmpfromico

Postby nageswaragunupudi » Wed Jul 08, 2015 1:48 am

Mr Manuel

To get hBitmap from hIcon, this may be shorter and faster:
Code: Select all  Expand view  RUN
HB_FUNC (HICO2HBMP)  // HICO2HBMP( hIcon ) --> hBitmap
{
   ICONINFO iconinfo;

   GetIconInfo( (HICON) hb_parnl( 1 ), &iconinfo );
   hb_retnl( (LONG) iconinfo.hbmColor );

}
 


The new logic of ICON_EXEREAD is working great.
(does not appear to be compatible with bcc582 )
Regards

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

Re: bmpfromico

Postby mastintin » Wed Jul 08, 2015 7:00 am

Nages . the same code (no resize image ) ....
with

DeleteObject( oImage:hBitmap )
oImage:hBitmap = HICO2HBMP( hIcon )
oImage:HasAlpha()
oImage:Refresh()

Image

with

DeleteObject( oImage:hBitmap )
oGBmp:hBmp:= GDIPLUSIMAGEFROMICO( hIcon )
oImage:hBitmap:= oGBmp:GetGDIHbitmap()
oImage:HasAlpha()
oImage:Refresh()

Image
User avatar
mastintin
 
Posts: 1516
Joined: Thu May 27, 2010 2:06 pm

Re: bmpfromico

Postby mastintin » Wed Jul 08, 2015 7:53 am

change in ICON_EXEREAD for bcc582 compatiblility ... :-)

Code: Select all  Expand view  RUN


#include <commctrl.h>
#include <commoncontrols.h>

STDAPI SHGetImageList(int iImageList, REFIID riid, void **ppvObj);

HB_FUNC( ICON_EXEREAD )
{
   
 HICON hico ;  
 SHFILEINFO sfi = { 0 };
 LPCTSTR pName = ( LPCTSTR ) hb_parc( 1 ) ;
 
 SHGetFileInfo(  pName , -1, &sfi, sizeof(sfi), SHGFI_SYSICONINDEX  );
 
 HIMAGELIST* imageList;
 HRESULT hResult = SHGetImageList( hb_parni( 2 ) , __uuidof(IImageList), (void**)&imageList );
 if(hResult == S_OK) {
   ((IImageList*)imageList)->GetIcon(sfi.iIcon,ILD_NORMAL|ILD_TRANSPARENT , &hico);
  }
 
 #ifndef _WIN64
    hb_retnl( ( LONG )  hico );
 #else  
    hb_retnll( ( LONGLONG ) hico );
 #endif
 
}

 
User avatar
mastintin
 
Posts: 1516
Joined: Thu May 27, 2010 2:06 pm

Re: bmpfromico

Postby nageswaragunupudi » Wed Jul 08, 2015 7:59 am

Excellant.
Suggestion: Default 2nd parameter to 0, if the caller omits the 2nd parameter
Regards

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

Re: bmpfromico

Postby Silvio.Falconi » Sat Jul 11, 2015 5:42 pm

Dear Mastintin,
I had problems with my elderly mother and I was in the hospital with her Institute for the time. the return I saw the new sources that you did and I found this evening to compile. But I have problems as you can see
Code: Select all  Expand view  RUN

Progetto: TEST2, Ambiente: xFive_Pelles:
[1]:Harbour.Exe TEST2.PRG  /m /n0 /gc1 /es2 /iC:\Work\fwh\include /ic:\work\xHarbour\Include /jI18n\Main.hil /iinclude;c:\work\fwh\include;c:\work\xHarbour\include /oObj\TEST2.c
xHarbour 1.2.3 Intl. (SimpLex) (Build 20140725)
Copyright 1999-2014, http://www.xharbour.org http://www.harbour-project.org/
Compiling 'TEST2.PRG'...
Generating international list to 'I18n\Main.hil'...
Generating C source output to 'Obj\TEST2.c'...
Done.
Lines 41, Functions/Procedures 3, pCodes 248
[1]:Bcc32.Exe -M -c -O2  -tW -v- -X -DHB_FM_STATISTICS_OFF -DHB_NO_DEFAULT_API_MACROS -DHB_NO_DEFAULT_STACK_MACROS -DHB_OS_WIN_32 -IC:\Work\fwh\include -IC:\Work\bcc582\Include;c:\work\xHarbour\Include  -nObj Obj\TEST2.c
Borland C++ 5.82 for Win32 Copyright (c) 1993, 2005 Borland
Obj\TEST2.c:
[1]:Harbour.Exe tgdiplus.prg  /m /n0 /gc1 /es2 /iC:\Work\fwh\include /ic:\work\xHarbour\Include /jI18n\Main.hil /iinclude;c:\work\fwh\include;c:\work\xHarbour\include /oObj\tgdiplus.c
xHarbour 1.2.3 Intl. (SimpLex) (Build 20140725)
Copyright 1999-2014, http://www.xharbour.org http://www.harbour-project.org/
Compiling 'tgdiplus.prg'...
Generating international list to 'I18n\Main.hil'...
Generating C source output to 'Obj\tgdiplus.c'...
Done.
Lines 792, Functions/Procedures 39, pCodes 2855
[1]:Bcc32.Exe -M -c -O2  -tW -v- -X -DHB_FM_STATISTICS_OFF -DHB_NO_DEFAULT_API_MACROS -DHB_NO_DEFAULT_STACK_MACROS -DHB_OS_WIN_32 -IC:\Work\fwh\include -IC:\Work\bcc582\Include;c:\work\xHarbour\Include  -nObj Obj\tgdiplus.c
Borland C++ 5.82 for Win32 Copyright (c) 1993, 2005 Borland
Obj\tgdiplus.c:
[1]:Bcc32.Exe -M -c -O2  -tW -v- -X -DHB_FM_STATISTICS_OFF -DHB_NO_DEFAULT_API_MACROS -DHB_NO_DEFAULT_STACK_MACROS -DHB_OS_WIN_32 -IC:\Work\fwh\include -IC:\Work\bcc582\Include;c:\work\xHarbour\Include  -nObj gdiplus.cpp
Borland C++ 5.82 for Win32 Copyright (c) 1993, 2005 Borland
gdiplus.cpp:
Error E2209 C:\Work\bcc582\Include\gdiplus.h 21: Unable to open include file 'algorithm'
Error E2316 C:\Work\bcc582\Include\gdiplus.h 22: 'min' is not a member of 'std'
Error E2272 C:\Work\bcc582\Include\gdiplus.h 22: Identifier expected
Error E2316 C:\Work\bcc582\Include\gdiplus.h 23: 'max' is not a member of 'std'
Error E2272 C:\Work\bcc582\Include\gdiplus.h 23: Identifier expected
Error E2268 C:\Work\bcc582\Include\GdiplusTypes.h 459: Call to undefined function 'min' in function RectF::Intersect(RectF &,const RectF &,const RectF &)
Error E2268 C:\Work\bcc582\Include\GdiplusTypes.h 461: Call to undefined function 'max' in function RectF::Intersect(RectF &,const RectF &,const RectF &)
Error E2268 C:\Work\bcc582\Include\GdiplusTypes.h 483: Call to undefined function 'max' in function RectF::Union(RectF &,const RectF &,const RectF &)
Error E2268 C:\Work\bcc582\Include\GdiplusTypes.h 484: Call to undefined function 'max' in function RectF::Union(RectF &,const RectF &,const RectF &)
Error E2268 C:\Work\bcc582\Include\GdiplusTypes.h 485: Call to undefined function 'min' in function RectF::Union(RectF &,const RectF &,const RectF &)
Error E2268 C:\Work\bcc582\Include\GdiplusTypes.h 486: Call to undefined function 'min' in function RectF::Union(RectF &,const RectF &,const RectF &)
Error E2268 C:\Work\bcc582\Include\GdiplusTypes.h 647: Call to undefined function 'min' in function Rect::Intersect(Rect &,const Rect &,const Rect &)
Error E2268 C:\Work\bcc582\Include\GdiplusTypes.h 648: Call to undefined function 'min' in function Rect::Intersect(Rect &,const Rect &,const Rect &)
Error E2268 C:\Work\bcc582\Include\GdiplusTypes.h 649: Call to undefined function 'max' in function Rect::Intersect(Rect &,const Rect &,const Rect &)
Error E2268 C:\Work\bcc582\Include\GdiplusTypes.h 650: Call to undefined function 'max' in function Rect::Intersect(Rect &,const Rect &,const Rect &)
Error E2268 C:\Work\bcc582\Include\GdiplusTypes.h 671: Call to undefined function 'max' in function Rect::Union(Rect &,const Rect &,const Rect &)
Error E2268 C:\Work\bcc582\Include\GdiplusTypes.h 672: Call to undefined function 'max' in function Rect::Union(Rect &,const Rect &,const Rect &)
Error E2268 C:\Work\bcc582\Include\GdiplusTypes.h 673: Call to undefined function 'min' in function Rect::Union(Rect &,const Rect &,const Rect &)
Error E2268 C:\Work\bcc582\Include\GdiplusTypes.h 674: Call to undefined function 'min' in function Rect::Union(Rect &,const Rect &,const Rect &)
Error E2268 gdiplus.cpp 1115: Call to undefined function 'SHGetImageList' in function HB_FUN_ICON_EXEREAD()
Error E2451 gdiplus.cpp 1115: Undefined symbol 'IID_IImageList2' in function HB_FUN_ICON_EXEREAD()
*** 21 errors in Compile ***
 
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7086
Joined: Thu Oct 18, 2012 7:17 pm

Re: bmpfromico

Postby mastintin » Sat Jul 11, 2015 6:24 pm

I hope your mother gets better.
It seems a problem with the headers.
You should have declared these cvabeceras in gdiplus.cpp file.

Code: Select all  Expand view  RUN

#define STRICT
#include <windows.h>
#include <algorithm>
using std::min;
using std::max;

#include <hbapi.h>
#include <windows.h>
#include <gdiplus.h>
#include <hbapiitm.h>
#include <string>
#include <commctrl.h>
#include <commoncontrols.h>

#ifndef __GNUC__
   #include <gdiplusimaging.h>
#else
   #include <gdiplus/gdiplusimaging.h>
#endif

extern "C"
{
LPWSTR UTF8toUTF16( LPCSTR utf8 );
}

STDAPI SHGetImageList(int iImageList, REFIID riid, void **ppvObj);

 
User avatar
mastintin
 
Posts: 1516
Joined: Thu May 27, 2010 2:06 pm

Re: bmpfromico

Postby Silvio.Falconi » Mon Jul 13, 2015 10:44 pm

Sorry,
I write only now because I have to be in hospital with my mother who is under observation for an illness colon


I add the header and it make this error

Code: Select all  Expand view  RUN
Done.
Lines 792, Functions/Procedures 39, pCodes 2855
[1]:Bcc32.Exe -M -c -O2  -tW -v- -X -DHB_FM_STATISTICS_OFF -DHB_NO_DEFAULT_API_MACROS -DHB_NO_DEFAULT_STACK_MACROS -DHB_OS_WIN_32 -IC:\Work\fwh\include -IC:\Work\bcc582\Include;c:\work\xHarbour\Include  -nObj Obj\tgdiplus.c
Borland C++ 5.82 for Win32 Copyright (c) 1993, 2005 Borland
Obj\tgdiplus.c:
[1]:Bcc32.Exe -M -c -O2  -tW -v- -X -DHB_FM_STATISTICS_OFF -DHB_NO_DEFAULT_API_MACROS -DHB_NO_DEFAULT_STACK_MACROS -DHB_OS_WIN_32 -IC:\Work\fwh\include -IC:\Work\bcc582\Include;c:\work\xHarbour\Include  -nObj gdiplus.cpp
Borland C++ 5.82 for Win32 Copyright (c) 1993, 2005 Borland
gdiplus.cpp:
Error E2209 gdiplus.cpp 11: Unable to open include file 'algorithm'
Error E2316 gdiplus.cpp 12: 'min' is not a member of 'std'
Error E2272 gdiplus.cpp 12: Identifier expected
Error E2316 gdiplus.cpp 13: 'max' is not a member of 'std'
Error E2272 gdiplus.cpp 13: Identifier expected
Error E2209 C:\Work\bcc582\Include\gdiplus.h 21: Unable to open include file 'algorithm'
Error E2316 C:\Work\bcc582\Include\gdiplus.h 22: 'min' is not a member of 'std'
Error E2272 C:\Work\bcc582\Include\gdiplus.h 22: Identifier expected
Error E2316 C:\Work\bcc582\Include\gdiplus.h 23: 'max' is not a member of 'std'
Error E2272 C:\Work\bcc582\Include\gdiplus.h 23: Identifier expected
Error E2268 C:\Work\bcc582\Include\GdiplusTypes.h 459: Call to undefined function 'min' in function RectF::Intersect(RectF &,const RectF &,const RectF &)
Error E2268 C:\Work\bcc582\Include\GdiplusTypes.h 461: Call to undefined function 'max' in function RectF::Intersect(RectF &,const RectF &,const RectF &)
Error E2268 C:\Work\bcc582\Include\GdiplusTypes.h 483: Call to undefined function 'max' in function RectF::Union(RectF &,const RectF &,const RectF &)
Error E2268 C:\Work\bcc582\Include\GdiplusTypes.h 484: Call to undefined function 'max' in function RectF::Union(RectF &,const RectF &,const RectF &)
Error E2268 C:\Work\bcc582\Include\GdiplusTypes.h 485: Call to undefined function 'min' in function RectF::Union(RectF &,const RectF &,const RectF &)
Error E2268 C:\Work\bcc582\Include\GdiplusTypes.h 486: Call to undefined function 'min' in function RectF::Union(RectF &,const RectF &,const RectF &)
Error E2268 C:\Work\bcc582\Include\GdiplusTypes.h 647: Call to undefined function 'min' in function Rect::Intersect(Rect &,const Rect &,const Rect &)
Error E2268 C:\Work\bcc582\Include\GdiplusTypes.h 648: Call to undefined function 'min' in function Rect::Intersect(Rect &,const Rect &,const Rect &)
Error E2268 C:\Work\bcc582\Include\GdiplusTypes.h 649: Call to undefined function 'max' in function Rect::Intersect(Rect &,const Rect &,const Rect &)
Error E2268 C:\Work\bcc582\Include\GdiplusTypes.h 650: Call to undefined function 'max' in function Rect::Intersect(Rect &,const Rect &,const Rect &)
Error E2268 C:\Work\bcc582\Include\GdiplusTypes.h 671: Call to undefined function 'max' in function Rect::Union(Rect &,const Rect &,const Rect &)
Error E2268 C:\Work\bcc582\Include\GdiplusTypes.h 672: Call to undefined function 'max' in function Rect::Union(Rect &,const Rect &,const Rect &)
Error E2268 C:\Work\bcc582\Include\GdiplusTypes.h 673: Call to undefined function 'min' in function Rect::Union(Rect &,const Rect &,const Rect &)
Error E2268 C:\Work\bcc582\Include\GdiplusTypes.h 674: Call to undefined function 'min' in function Rect::Union(Rect &,const Rect &,const Rect &)
Error E2209 gdiplus.cpp 19: Unable to open include file 'string'
Error E2228 gdiplus.cpp 19: Too many error or warning messages
*** 26 errors in Compile ***
 
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7086
Joined: Thu Oct 18, 2012 7:17 pm

Re: bmpfromico

Postby mastintin » Tue Jul 14, 2015 7:06 am

Silvio .
You have algorithm in c:\bcc582\include\dinkumware ?
if you are this file . Add the path c:\bcc582\include\dinkumware -I%bcdir%\include\dinkumware
Code: Select all  Expand view  RUN


Bcc32.Exe -M -c -O2  -tW -v- -X -DHB_FM_STATISTICS_OFF -DHB_NO_DEFAULT_API_MACROS -DHB_NO_DEFAULT_STACK_MACROS -DHB_OS_WIN_32 -IC:\Work\fwh\include -IC:\Work\bcc582\Include;c:\Work\bcc582\include\dinkumware;c:\work\xHarbour\Include  -nObj gdiplus.cpp
 
User avatar
mastintin
 
Posts: 1516
Joined: Thu May 27, 2010 2:06 pm

Re: bmpfromico

Postby Silvio.Falconi » Tue Jul 14, 2015 1:50 pm

Manuel ,
now I can compile the test
open the test and select a file ( test.pdf)
it create the bitmap and make this error

Code: Select all  Expand view  RUN
Application
===========
   Path and name: C:\Work\Errori\GDIPLUS\TEST2.Exe (32 bits)
   Size: 2,649,088 bytes
   Compiler version: xHarbour 1.2.3 Intl. (SimpLex) (Build 20140725)
   FiveWin  Version: FWHX 15.01
   Windows version: 6.1, Build 7600

   Time from start: 0 hours 0 mins 34 secs
   Error occurred at: 07/14/15, 15:49:11
   Error description: Warning BASE/1004  Message not found: GDIBMP:END

Stack Calls
===========
   Called from: source\rtl\tobject.prg => GDIBMP:ERROR( 0 )
   Called from: source\rtl\tobject.prg => GDIBMP:MSGNOTFOUND( 0 )
   Called from: source\rtl\tobject.prg => GDIBMP:END( 0 )
   Called from: TEST2.PRG => GDIBMPFROMHICON( 37 )
   Called from: TEST2.PRG => IMAGENFROMICO( 24 )
   Called from: TEST2.PRG => (b)MAIN( 9 )
   Called from: .\source\classes\BUTTON.PRG => TBUTTON:CLICK( 175 )
   Called from: .\source\classes\CONTROL.PRG => TBUTTON:HANDLEEVENT( 1687 )
   Called from: .\source\classes\WINDOW.PRG => _FWH( 3450 )
   Called from:  => SENDMESSAGE( 0 )
   Called from: .\source\classes\WINDOW.PRG => TWINDOW:COMMAND( 1207 )
   Called from:  => TWINDOW:HANDLEEVENT( 0 )
   Called from: .\source\classes\WINDOW.PRG => _FWH( 3450 )
   Called from:  => WINRUN( 0 )
   Called from: .\source\classes\WINDOW.PRG => TWINDOW:ACTIVATE( 1152 )
   Called from: TEST2.PRG => MAIN( 15 )
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7086
Joined: Thu Oct 18, 2012 7:17 pm

Re: bmpfromico

Postby Silvio.Falconi » Tue Jul 14, 2015 2:05 pm

Manuel the test run ok now I rem *ogbmp:end()

a problem the test fit the image good

I insert the new code into my app and I not found the right resize
I use a image control into a Tpanel control ( i tried 64x64 128x128)



your test good


Image


my app ( with image control into a tpanel )

Image


how I resolve ?
Last edited by Silvio.Falconi on Tue Jul 14, 2015 2:23 pm, edited 1 time in total.
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7086
Joined: Thu Oct 18, 2012 7:17 pm

Re: bmpfromico

Postby mastintin » Tue Jul 14, 2015 2:22 pm

2 questions.

1.-
look in the function gdiplus.cpp if you have GDIPLUSIMAGEDISPOSE .if not exist add it.

Code: Select all  Expand view  RUN


HB_FUNC( GDIPLUSIMAGEDISPOSE )
{
  Bitmap * newImage = ( Bitmap * ) hb_parnl( 1 );
   delete newImage;
}

 


change
ogdibmp:end()

for

GDIPLUSIMAGEDISPOSE( ogdibmp:hbmp)

2.-


GDIBmpFromHIcon( ico, oImage , oImage:Super:nWidth(), oImage:Super:nHeight() )

change oImage:Super:nWidth() and oImage:Super:nHeight() for 64*64 or your prefered size .
User avatar
mastintin
 
Posts: 1516
Joined: Thu May 27, 2010 2:06 pm

Re: bmpfromico

Postby Silvio.Falconi » Tue Jul 14, 2015 2:30 pm

First question I coorect GDIPLUSIMAGEDISPOSE( ogdibmp:hbmp)
make error
Code: Select all  Expand view  RUN
Application
===========
   Path and name: C:\Work\Prg\Allegati\Allegati.Exe (32 bits)
   Size: 2,974,720 bytes
   Compiler version: xHarbour 1.2.3 Intl. (SimpLex) (Build 20140725)
   FiveWin  Version: FWHX 15.01
   Windows version: 6.1, Build 7600

   Time from start: 0 hours 0 mins 5 secs
   Error occurred at: 07/14/15, 16:27:21
   Error description: Error BASE/1003  Variable does not exist: OGDIBMP

Stack Calls
===========
   Called from: source\test.prg => GDIBMPFROMHICON( 456 )
   Called from: source\test.prg => IMAGENFROMICO( 430 )
   Called from: source\test.prg => SETFILE( 356 )
   Called from: source\test.prg => DROP( 240 )
   Called from: source\test.prg => (b)CREALISTVIEW( 295 )
   Called from: .\source\classes\WINDOW.PRG => TLISTVIEW:DROPFILES( 1363 )
   Called from:  => TWINDOW:HANDLEEVENT( 0 )
   Called from: .\source\classes\CONTROL.PRG => TLISTVIEW:HANDLEEVENT( 1733 )
   Called from: .\source\classes\WINDOW.PRG => _FWH( 3450 )
   Called from:  => DIALOGBOXINDIRECT( 0 )
   Called from: .\source\classes\DIALOG.PRG => TDIALOG:ACTIVATE( 286 )
   Called from: source\test.prg => ALLEGATI( 110 )



for the second question I tried 64x64 and it is not clear
please see it ( 64X64)


Image
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7086
Joined: Thu Oct 18, 2012 7:17 pm

Re: bmpfromico

Postby mastintin » Tue Jul 14, 2015 2:41 pm

1.-
silvio put your code for GDIBmpFromHIcon.

2.- The original measure icon is 256 * 256

ICON_EXEREAD function has 2 parameters name file , and Size ..
0->LARGE 32x32
1->SMALL 16x16
2->48x48
3-> These images are the size specified by GetSystemMetrics called with SM_CXSMICON and GetSystemMetrics called with SM_CYSMICON.
4-> Windows Vista and later. The image is normally 256x256 pixels.
User avatar
mastintin
 
Posts: 1516
Joined: Thu May 27, 2010 2:06 pm

Re: bmpfromico

Postby Silvio.Falconi » Tue Jul 14, 2015 6:20 pm

Code: Select all  Expand view  RUN
               IF lFileImage
                         oImagePreview:LoadBmp(cFileImage)
                         oImagePreview:setpos(0,0)
                         oImagePreview:nWidth:=oPanelPreview:nWidth
                         oImagePreview:nHeight:=oPanelPreview:nHeight
                         oImagePreview:lStretch:= .t.
                         oImagePreview:nZoom:= 1
                         oImagePreview:refresh()
                      else

                         ico := ICON_EXEREAD( cFile, 4  )
                        GDIBmpFromHIcon( ico, oImagePreview ,256,256 )

                      endif







....


Function GDIBmpFromHIcon( hIcon , oImagePreview , nWidth, nHeight )
local ogbmp := GdiBmp():new()
ogbmp:hBmp:= GDIPLUSIMAGEFROMICO( hicon )
ogbmp:resize( nWidth,nHeight)
DeleteObject( oImagePreview:hBitmap )
oImagePreview:hBitmap := oGBmp:GetGDIHbitmap()
oImagePreview:HasAlpha()
oImagePreview:Refresh()
*ogbmp:end()
*GDIPLUSIMAGEDISPOSE( ogdibmp)
Return nil
 





THE PROBLEM IS :

on your test you use a BTIMAP control
@ 3, 38 BITMAP oimage FILE "" size 220,220 of oWnd


on my application I use a oImage control

@ 0, 0 IMAGE oImagePreview SIZE oPanelPreview:nRight, oPanelPreview:nbottom OF oPanelPreview NOBORDER



on Image control gdi not run ok

I need to use oImage control because I select any files ( image or document file )

Image ==> *.bmp;*.gif;*.jpg;*.png;*.tif
document files == >*.pdf *.doc,*.xls,*.ppt,*.docx,*.xlsx,*.pptx *.odt,*.ods,*.odp, *.sxw, *.sxc,*. sxi

I think it is the problem
I made also a test change your control Bitmap into Image control and gdi not run

the code test
Code: Select all  Expand view  RUN

#include "FiveWin.ch"
#include "constant.ch"

Function Main ()
local ownd
local oimage

   Local nBottom   := 33
   Local nRight    := 75
   Local nWidth :=  Max( nRight * DLG_CHARPIX_W, 180 )
   Local nHeight := nBottom * DLG_CHARPIX_H

   DEFINE DIALOG oWnd  ;   //OF oParent
   TITLE "test"    ;
   SIZE nWidth, nHeight TRANSPARENT PIXEL

      oWnd:nStyle    := nOr( WS_OVERLAPPED,WS_THICKFRAME,WS_SYSMENU,WS_MAXIMIZEBOX,   0  )

    @ 20,2 button "crear" size 40,20 pixel Action imagenfromico(oimage )

    @ 20 ,130 Button "salir" Action ownd:end() size 40,20 pixel

   @ 3, 38 Image oimage FILE "" size 220,220 of oWnd

   ACTIVATE dialog oWnd


Return (nil)


Function imagenfromico(oImage )
local cFile:= cGetfile("coge","*.*")
local ico := ICON_EXEREAD( cFile, 4  ) // for ico, dll and exe files
GDIBmpFromHIcon( ico, oImage , oImage:Super:nWidth(), oImage:Super:nHeight() )

Return nil


Function GDIBmpFromHIcon( hIcon , oImage , nWidth, nHeight )
local ogbmp := GdiBmp():new()
ogbmp:hBmp:= GDIPLUSIMAGEFROMICO( hicon )
ogbmp:resize( nWidth,nHeight)
DeleteObject( oImage:hBitmap )
oImage:hBitmap := oGBmp:GetGDIHbitmap()
oImage:HasAlpha()
oImage:Refresh()
*ogbmp:end()

Return nil


when you select the file then not show any image into Image control
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7086
Joined: Thu Oct 18, 2012 7:17 pm

Re: bmpfromico

Postby mastintin » Wed Jul 15, 2015 5:45 am

ok. Silvio ,I would look like with a control image....
in your code change GDIPLUSIMAGEDISPOSE( ogdibmp) to GDIPLUSIMAGEDISPOSE( ogbmp:hbmp) .

----------------edito -------------------------------------

Silvio in your test is placing the image control within the dialogue out of sight .

Change to
@ 3, 8 Image oimage FILE "" size 220,220 of oWnd and and run ... is fine for me.
User avatar
mastintin
 
Posts: 1516
Joined: Thu May 27, 2010 2:06 pm

PreviousNext

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 26 guests