XIMage Compatibility with Image

XIMage Compatibility with Image

Postby Silvio.Falconi » Sat Jan 06, 2018 9:51 pm

I'm trying to converte image with ximage but I have some problems

Wich is the comand lStretch into xImage ?
wich is the comand ScrollAdjust into ximage

I tried to zoo an ximage but not run

Local aItemsZoom:={"25%","50%","75%","100%","150%","200%"}

@ 230,295 COMBOBOX oCbxZoom VAR nZoom ITEMS aItemsZoom SIZE 60, 10 of oAllegati ;
on change (oImagePreview:nZoom(val(aItemsZoom[nZoom])/100) ,;
oImagePreview:refresh() ,;
Rinfresca_oDlgallegati() )
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: 7076
Joined: Thu Oct 18, 2012 7:17 pm

Re: XIMage Compatibility with Image

Postby nageswaragunupudi » Sat Jan 06, 2018 11:31 pm

The user does not need to help of combobox or any other means to zoom / unzoom ximage.
He can zoom or unzoom with mouse wheel ( or zoom and pinch gestures on a touch screen ). This gives much smoother zooming experience as well as the ability to choose the center (point of interest) of zooming.

Stretch is not provided intentionally because there is no point in viewing an image with distorted aspect. Ximage always keeps aspect ratio undisturbed.
Regards

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

Re: XIMage Compatibility with Image

Postby Silvio.Falconi » Sun Jan 07, 2018 8:50 pm

Rao,
After many problems I resolve some problems but I have two other problems, see the picture

Image


I can show the icon of documents but the image is too big , I wish have a small image
I see black background why ?
then I not understood how run the zoom
i try with oImagePreview:nZoom(5) but not happen nothing
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: 7076
Joined: Thu Oct 18, 2012 7:17 pm

Re: XIMage Compatibility with Image

Postby nageswaragunupudi » Mon Jan 08, 2018 12:01 am

May I know how are you reading the icon and how are you showing with ximage?
Regards

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

Re: XIMage Compatibility with Image

Postby Silvio.Falconi » Mon Jan 08, 2018 12:48 pm

for the size of Image I found the error I used the method setsize for xmage and Tpanel
now is good ( 200x200)

To read th eicon of document I use

Code: Select all  Expand view  RUN
 ico := ICON_EXEREAD( cFile, 4  )
 GDIBmpFromHIcon( ico, oImagePreview , oImagePreview:Super:nWidth(), oImagePreview:Super:nHeight() )

Function GDIBmpFromHIcon( hIcon , oImagePreview , nWidth, nHeight )
local ogbmp := GdiBmp():new()
ogbmp:hBmp:= GDIPLUSIMAGEFROMICO( hicon )
ogbmp:resize( nWidth,nHeight)
oImagePreview:SetSource(oGBmp:GetGDIHbitmap() )
oImagePreview:Refresh()
Return nil


probable GDIPLUSIMAGEFROMICO non run good

ximage is open normal as :

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

oPanelPreview is a Tpanel and oPanelPreview:oClient:= oImagePreview
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: 7076
Joined: Thu Oct 18, 2012 7:17 pm

Re: XIMage Compatibility with Image

Postby mastintin » Mon Jan 08, 2018 3:19 pm

Silvio , you resize icon to oPanelPreview:nRight, oPanelPreview:nbottom
in
ogbmp:resize( nWidth,nHeight)

and that is the result exactly what do you get...
User avatar
mastintin
 
Posts: 1516
Joined: Thu May 27, 2010 2:06 pm

Re: XIMage Compatibility with Image

Postby Silvio.Falconi » Mon Jan 08, 2018 5:51 pm

Manuel,
I resolved for the size of Icon
the problem is I see black background arround the icon see the picture here:

Image


then I wish Know if it is possible save the image files into different formats and wich, thanks

Can I disable mousewheel (zoom) it the document is not an image file but only an Icon of document ?
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: 7076
Joined: Thu Oct 18, 2012 7:17 pm

Re: XIMage Compatibility with Image

Postby mastintin » Mon Jan 08, 2018 7:13 pm

Silvio .
Code: Select all  Expand view  RUN

ogbmp:hBmp:= GDIPLUSIMAGEFROMICO( hicon )
ogbmp:save( "icono.png")  // is posible png,jpg,bmp,tif

oImagePreview:SetSource("icono.png" )
oImagePreview:Refresh()
ferase( "icono.png" )
ogbmb:end()

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

Re: XIMage Compatibility with Image

Postby Silvio.Falconi » Mon Jan 08, 2018 7:54 pm

This function not run

Code: Select all  Expand view  RUN
Function GDIBmpFromHIcon( hIcon , oImagePreview , nWidth, nHeight )
local ogbmp := GdiBmp():new()
ogbmp:hBmp:= GDIPLUSIMAGEFROMICO( hicon )
ogbmp:save( "icono.png")  // is posible png,jpg,bmp,tif
oImagePreview:SetSource("icono.png" )
ogbmp:resize( nWidth,nHeight)
oImagePreview:Refresh()
ferase( "icono.png" )
ogbmp:end()
Return ni


first error
Code: Select all  Expand view  RUN
Application
===========
   Path and name: C:\Work\Prg\test_allegati\Allegati.Exe (32 bits)
   Size: 3,786,752 bytes
   Compiler version: Harbour 3.2.0dev (r1703231115)
   FiveWin  version: FWH 17.12
   C compiler version: Borland/Embarcadero C++ 7.0 (32-bit)
   Windows version: 6.2, Build 9200

   Time from start: 0 hours 0 mins 3 secs
   Error occurred at: 01/08/18, 20:50:53
   Error description: Error BASE/1004  Message not found: GDIBMP:END
   Args:
     [   1] = O   GDIBMP

Stack Calls
===========
   Called from:  => __ERRRT_SBASE( 0 )
   Called from: ../../../tobject.prg => GDIBMP:ERROR( 0 )
   Called from: ../../../tobject.prg => (b)HBOBJECT( 0 )
   Called from: ../../../tobject.prg => GDIBMP:MSGNOTFOUND( 0 )
   Called from: ../../../tobject.prg => GDIBMP:END( 0 )
   Called from: Source\test.prg => GDIBMPFROMHICON( 649 )
   Called from: Source\test.prg => INSERISCIALLEGATI( 241 )
   Called from: Source\test.prg => (b)ALLEGATI( 180 )
   Called from: .\source\classes\DIALOG.PRG => TDIALOG:INITIATE( 714 )
   Called from: .\source\classes\DIALOG.PRG => TDIALOG:HANDLEEVENT( 906 )
   Called from:  => DIALOGBOXINDIRECT( 0 )
   Called from: .\source\classes\DIALOG.PRG => TDIALOG:ACTIVATE( 296 )
   Called from: Source\test.prg => ALLEGATI( 180 )
   Called from: Source\test.prg => TEST( 56 )
 


if I rem the line ogbmp:end()

I not see any image




If the function is this
Code: Select all  Expand view  RUN
Function GDIBmpFromHIcon( hIcon , oImagePreview , nWidth, nHeight )
Local hBmp
local ogbmp := GdiBmp():new()
ogbmp:hBmp:= GDIPLUSIMAGEFROMICO( hicon )
ogbmp:resize( nWidth,nHeight)

                       if oImagePreview:cargo == NIL
                          oImagePreview:cargo =  oImagePreview:GetHBitmap()
                       else
                          DeleteObject( oImagePreview:GetHBitmap() )
                       endif

 hBmp := oGBmp:GetGDIHbitmap()

oImagePreview:SetSource( hBmp )

oImagePreview:Refresh()

Return nil


I see the icon on oImagePreview but with black background

I saw there is this function GDIP_NEWALPHABMP How I can use it to erase black background ?
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: 7076
Joined: Thu Oct 18, 2012 7:17 pm

Re: XIMage Compatibility with Image

Postby mastintin » Mon Jan 08, 2018 9:31 pm

this is good for me ...
Code: Select all  Expand view  RUN


#include "fivewin.ch"

//----------------------------------------------------------------------------//

function Main()

   local aImages, oWnd, oFont, oBrush, oBrw, oImage

   FW_SetUnicode( .t. )
   HB_SETCODEPAGE( "UTF8" ) // Harbour (not xHarbour) to display unicode filenames

   aImages  := ReadFolder()

   DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-15
   DEFINE BRUSH oBrush FILE "..\bitmaps\backgrnd\stone.bmp"
   DEFINE WINDOW oWnd
   oWnd:SetFont( oFont )

   msginfo( len( aImages ) )
 
   DEFINE BUTTONBAR oWnd:oBar SIZE 100,32 2007
   SET MESSAGE OF oWnd TO "" 2007

   DEFINE BUTTON OF oWnd:oBar PROMPT "Center"     CENTER ACTION ( oImage:Center(),    oImage:SetFocus() )
   DEFINE BUTTON OF oWnd:oBar PROMPT "Fit Width"  CENTER ACTION ( oImage:FitWidth(),  oImage:SetFocus() )
   DEFINE BUTTON OF oWnd:oBar PROMPT "Fit Height" CENTER ACTION ( oImage:FitHeight(), oImage:SetFocus() )
   DEFINE BUTTON OF oWnd:oBar PROMPT "Fit Rect"   CENTER ACTION ( oImage:FitRect(),   oImage:SetFocus() )
   DEFINE BUTTON OF oWnd:oBar PROMPT "Rotate"     CENTER ACTION ( oImage:Rotate(),    oImage:SetFocus() )
   DEFINE BUTTON OF oWnd:oBar PROMPT "Zoom"       CENTER ACTION ( MsgInfo( "Zoom/Unzoom with Mouse Wheel" ),  oImage:SetFocus() )
   DEFINE BUTTON OF oWnd:oBar PROMPT "Pan/Move"   CENTER ACTION ( MsgInfo( "Drag with Mouse" ),  oImage:SetFocus() )


   @ oWnd:oBar:nHeight,0 XBROWSE oBrw SIZE 300,-oWnd:oMsgBar:nHeight ;
      PIXEL OF oWnd DATASOURCE aImages COLUMNS 1 ;
      CELL LINES NOBORDER

   WITH OBJECT oBrw
      :nStretchCol   := 1
      :bChange       := { || carga( oBrw:aRow[ 2 ],oImage ) }
      //
      :CreateFromCode()
   END

   @ oWnd:oBar:nHeight,300 XIMAGE oImage SIZE 0,-oWnd:oMsgBar:nHeight ;
      OF oWnd SOURCE ""   //MEMOREAD( oBrw:aRow[ 2 ] )

   oImage:SetBrush( oBrush )

   WITH OBJECT oWnd
      :nWidth     := ScreenWidth()  * 0.6
      :nHeight    := ScreenHeight() * 0.6
   END

   ACTIVATE WINDOW oWnd CENTERED
   RELEASE FONT oFont
   RELEASE BRUSH oBrush


return nil

//----------------------------------------------------------------------------//

static function ReadFolder

   local aImages  := {}
      local c, cPath, aDir

 
      cPath    := ".\"
      aDir     := Directory( cPath + "
*.*" )
      AEval( aDir, { |a| If( a[ 2 ] > 32000, AAdd( aImages, { a[ 1 ], TrueName( cPath + a[ 1 ] ) } ), nil ) } )
   

   ASort( aImages,,,{ |x,y| Lower( x[ 1 ] ) < Lower( y[ 1 ] ) } )

return aImages

//----------------------------------------------------------------------------//

static function carga( cFile , oImage )
local hicon := ICON_EXEREAD( cFile, 4  )
local ogbmp := GdiBmp():new()

ogbmp:hBmp:= GDIPLUSIMAGEFROMICO( hicon )

oimage:SetSource( ogBmp:GetGDIHbitmap() )
oImage:Refresh()
ogbmp:end()

Return nil


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

Re: XIMage Compatibility with Image

Postby mastintin » Mon Jan 08, 2018 9:51 pm

other approach is ---

Code: Select all  Expand view  RUN


static function carga( cFile , oImage )
local hicon := ICON_EXEREAD( cFile, 4  )
local ogbmp := GdiBmp():new()

ogbmp:hBmp:= GDIPLUSIMAGEFROMICO( hicon )
ogbmp:save( "icono.png")
oimage:SetSource( memoread( "icono.png" ) )
oImage:Refresh()
ferase("icono.png" )
ogbmp:end()

Return nil


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

Re: XIMage Compatibility with Image

Postby Silvio.Falconi » Mon Jan 08, 2018 10:15 pm

I compiled your test

I change only the path cPath := ".\Doc\"

where I put these files to try the test

Image

But when I run the exe I see only six files

Image

then I try t select one for a sample tga file

Image

or another for sample the pdf file

Image


Probable there is something not run ok , isn'it ?
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: 7076
Joined: Thu Oct 18, 2012 7:17 pm

Re: XIMage Compatibility with Image

Postby mastintin » Tue Jan 09, 2018 8:12 am

Yes. Silvio .

HB_FUNC( GDIPLUSIMAGEFROMICO ) from fwh has a bug, in my gdiplus.cpp version is corrected.
I have reported it to Cristobal for correction.

The code propose by nages is more good solution : :-)

Code: Select all  Expand view  RUN

static function carga( cFile , oImage )

local hicon := ICON_EXEREAD( cFile, 4  )
local   hBmp  := HBMPFROMHICON( hIcon )
   DestroyIcon( hIcon )
   oImage:SetSource( hBmp )
   DeleteObject( hBmp )

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

Re: XIMage Compatibility with Image

Postby Silvio.Falconi » Tue Jan 09, 2018 8:24 am

yes Rao Function Run Good

Image


GDIPLUSIMAGEFROMICO in gdiplus have bug

I have 3 different function

1. the yours ( here not pubblish)

2. the version on fwh12 ( where I see nothing)

Code: Select all  Expand view  RUN

HB_FUNC( GDIPLUSIMAGEFROMICO )
{
 HICON hIcon = ( HICON ) fw_parH( 1 ) ;

 ICONINFO ii ;
 GetIconInfo(hIcon, &ii);
 BITMAP bmp;
 //GetObject(ii.hbmColor, sizeof(bmp), &bmp);
 //GetObject(ii.hbmMask, sizeof(bmp), &bmp);

 //Bitmap * temp = new Bitmap(ii.hbmColor, NULL);
 Bitmap * temp = new Bitmap(ii.hbmMask, NULL);

 DeleteObject(ii.hbmColor);
 DeleteObject(ii.hbmMask);

 Bitmap* newImage =  BitmapFromAlphaBmp( temp ) ;

 hb_retptr( newImage );

}
 



3 . an oldest release where I see the icon with black background
Code: Select all  Expand view  RUN
HB_FUNC( GDIPLUSIMAGEFROMICO )
{
   HICON hIcon = ( HICON ) fw_parH( 1 ) ;

   Bitmap * newImage =  new Bitmap( hIcon );
   hb_retptr( newImage );
}
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: 7076
Joined: Thu Oct 18, 2012 7:17 pm


Return to FiveWin for Harbour/xHarbour

Who is online

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

cron