FWH 1801: Enhancements to TBitmap class

FWH 1801: Enhancements to TBitmap class

Postby nageswaragunupudi » Sun Feb 18, 2018 2:38 am

Till FWH 17.12, TBitmap class was able to display only bmp and png files/resources. For displaying other formats, its derived class TImage class was to be used. But TImage class requires freeimage.dll.

TXImage class is available for displaying bmp,png,jpg,gif,ico,cur,tif,emf,wmf formats without freeimage.dll and more formats if freeimage.dll is available. But the class methods and user-interface is much different from the TBitmap and TImage.

From version 18.01, TBitmap class itself can handle all image formats bmp,png,jpg,gif,ico,cur,tif,emf,wmf without freeimage.dll and more with the dll. Thus in most cases, TBitmap meets the requirements without having to use TImage.

The choice between TBitmap and TXImage depends only on the kind of interface prefered by the programmer than the capabilities to handle a variety of image formats.

A test program:
Code: Select all  Expand view
#include "fivewin.ch"

function Main()

   local oDlg, oBrush, oFont, oBmp

   DEFINE FONT oFont NAME "Segoe UI" SIZE 0,-16 BOLD
   DEFINE BRUSH oBrush FILE "\fwh\bitmaps\backgrnd\stone.bmp"

   DEFINE DIALOG oDlg SIZE 1050,700 PIXEL TRUEPIXEL TRANSPARENT ;
      TITLE "FWH 1801 : TBITMAP Control" BRUSH oBrush

   @  20, 20 BITMAP oBmp SIZE 150,150 PIXEL OF oDlg ;
      FILE "\fwh\bitmaps\alphabmp\android.bmp" NOBORDER

   @  20,200 BITMAP oBmp SIZE 150,150 PIXEL OF oDlg ;
      FILE "\fwh\bitmaps\pngs\dvd.png" NOBORDER

   @  20,400 BITMAP oBmp SIZE 150,150 PIXEL OF oDlg ;
      FILE "leaves.wmf" NOBORDER

   oBmp:nZoom  := 0.08

   @  20,600 BITMAP oBmp SIZE 150,150 PIXEL OF oDlg ;
      FILE "\fwh\icons\hires\auxiliarydisplay.ico(128x128)" NOBORDER

   @  20,750 BITMAP oBmp SIZE 300,400 PIXEL OF oDlg ;
      FILE "\fwh\gifs\test3.gif" NOBORDER

   @ 200, 20 BITMAP oBmp SIZE 350,450 PIXEL OF oDlg ;
      FILE "\fwh\bitmaps\olga1.jpg" NOBORDER

   @ 200,390 BITMAP oBmp SIZE 390,450 PIXEL OF oDlg ;
      FILE "https://wikitravel.org/upload/en/thumb/3/32/Paris-eiffel-tower.jpg/300px-Paris-eiffel-tower.jpg" ;
      NOBORDER

   for each oBmp in oDlg:aControls
      if oBmp:ClassName() == "TBITMAP"
         @ oBmp:nTop + oBmp:Super:nHeight, oBmp:nLeft SAY Upper( cFileExt( oBmp:cBmpFile ) ) ;
            SIZE oBmp:Super:nWidth, 20 PIXEL OF oDlg CENTER FONT oFont
      else
         EXIT
      endif
   next

   ACTIVATE DIALOG oDlg CENTERED
   RELEASE FONT oFont
   RELEASE BRUSH oBrush

return nil


Image
Regards

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

Re: FWH 1801: Enhancements to TBitmap class

Postby Enrico Maria Giordano » Sun Feb 18, 2018 10:02 am

nageswaragunupudi wrote:TXImage class is available for displaying bmp,png,jpg,gif,ico,cur,tif,emf,wmf formats without freeimage.dll


I'm trying to use GDIP_IMAGEFROMFILE() to load a .CUR file but the result is zero. It works fine with all the other image formats.

Any ideas?

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

Re: FWH 1801: Enhancements to TBitmap class

Postby nageswaragunupudi » Sun Feb 18, 2018 10:40 am

GDIP_ImageFromFile() is working with Icons but not with cursors. We need to look into it and we will.

We did not pay much attention to it, because even for icons this function is not greatly useful because we do not have much control on the size.

Instead, we got better results using Classic GDI Icon-read functions. Once we retrieve hIcon/hCursor then we either diretly draw or convert to bitmap or gdi+ image depending on the requirements.

For quick results, we can now use
oWnd:ReadImage( "cfile.cur" ) --> hBitmap
oWnd:ReadImage( "cfile.cur",,.T. ) --> gdi+ image
Regards

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

Re: FWH 1801: Enhancements to TBitmap class

Postby Enrico Maria Giordano » Sun Feb 18, 2018 11:13 am

nageswaragunupudi wrote:GDIP_ImageFromFile() is working with Icons but not with cursors. We need to look into it and we will.

We did not pay much attention to it, because even for icons this function is not greatly useful because we do not have much control on the size.

Instead, we got better results using Classic GDI Icon-read functions. Once we retrieve hIcon/hCursor then we either diretly draw or convert to bitmap or gdi+ image depending on the requirements.

For quick results, we can now use
oWnd:ReadImage( "cfile.cur" ) --> hBitmap
oWnd:ReadImage( "cfile.cur",,.T. ) --> gdi+ image


Thank you. How to load a .CUR without using a windows or other controls? Is this the correct way?

Code: Select all  Expand view
FW_ReadImage( , "cfile.cur" ) --> hBitmap


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

Re: FWH 1801: Enhancements to TBitmap class

Postby nageswaragunupudi » Sun Feb 18, 2018 11:51 am

Yes
Regards

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

Re: FWH 1801: Enhancements to TBitmap class

Postby Enrico Maria Giordano » Sun Feb 18, 2018 1:25 pm

Works fine, thank you. Is this the full list of supported formats?

Code: Select all  Expand view
bmp,png,jpg,gif,ico,cur,tif,emf,wmf


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

Re: FWH 1801: Enhancements to TBitmap class

Postby nageswaragunupudi » Sun Feb 18, 2018 1:29 pm

Enrico Maria Giordano wrote:Works fine, thank you. Is this the full list of supported formats?

Code: Select all  Expand view
bmp,png,jpg,gif,ico,cur,tif,emf,wmf


EMG

Yes.
This is the list of formats it reads without freeimage.dll.
In case freeimage.dll is available in the exe path, the function automatically uses the dll and can read other image formats also.
If the file can not be read as an image, the file's application icon is read.

In addition, we can also use FW_ShapesArray or Segoe/Wingding symbol asc values.

The function returns an array with relevant information about the image data.
The first element can be GDI+ pImage (if opted), hBitmap, hIcon, hMeta, Segoe Symbol.

It is desirable (though not essential) to send the entire array as it is to FW_DrawImage( hDC, aBmpInfo, ... )
Regards

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



Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 96 guests