FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Image-Zoom possible with NON transparent Images ?
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Image-Zoom possible with NON transparent Images ?
Posted: Sat Apr 16, 2011 05:19 PM
Hello,

testing the Zoom-function of the Image-viewer I noticed :
All Images < BMP with Alphachannel, PNG > it is possible to Zoom with adjusted Dialog to Imagesize.
Maybe I have to use a different Solution for NON transparent Images.
I remember, that it is possible to detect a Alpha-channel from a Image.

Tested, but with wrong Return-Values ( Icons return .F. ) JPG's are OK.
DEFINE IMAGE oImage FILE cImgname
msgalert( HasAlpha( oImage:hBitmap ) )


Case32.bmp doesn't have a Alpha-channel, only a Backgroundcolor. I think the Reason, that returns .F.



@ 0, 0 IMAGE oImage FILE cImgname SIZE nWidth, nHeight NOBORDER PIXEL
oImage:lTransparent := .T.
oImage:Zoom( nZoom )


impossible, to Zoom a NON transparent Image (ignored ).



Added Alphachannel to a < normal BMP > it works.



In Class Bitmap, maybe something is missing ?
Code (fw): Select all Collapse
...
...
         if ::nZoom > 0
            if SetAlpha() .and. ::lHasAlpha
               hBitmap := resizebmp( ::hBitmap, ::nWidth, ::nHeight )
               ABPaint( ::hDC, ::nX, ::nY, hBitmap, ::nAlphaLevel() )
            else
              if ! ::lTransparent
                  PalBmpDraw( ::hDC, ::nX, ::nY, ::hBitmap, ::hPalette,;
                              ::nWidth(), ::nHeight(),, ::lTransparent, ::nClrPane )
               else
                  hBmpOld = SelectObject( ::hDC, ::hBitmap )
                  nZeroZeroClr = GetPixel( ::hDC, 0, 0 )
                  SelectObject( ::hDC, hBmpOld )
                  nOldClr = SetBkColor( ::hDC, nRGB( 255, 255, 255 ) )
                  TransBmp( ::hBitmap, ::nWidth(), ::nHeight(), nZeroZeroClr, ::hDC,;
                            ::nY, ::nX, ::nWidth(), ::nHeight() )
                  SetBkColor( ::hDC, nOldClr )
               endif
            endif
         endif
      endif
...
...


Best Regards
Uwe :-)
Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Image-Zoom possible with NON transparent Images ?
Posted: Sat Apr 16, 2011 11:14 PM

If an image has alpha channel TImage detects the alpha channel and paints transparently. In all other cases, the programmer has to decide whether to paint transparently or not, by setting oImage:lTranparent.

The question is how the programmer can decide whether to paint transparently or not? This is not easy.

As a thumb rule, jpg's do not have transparency information. png normally can be assumed to have transparent information. For bitmaps it is difficult to decide if it has a transparent background or not.

I suggest that for non-alpha images, lTransparent can be .f. by default for jpg, .t. for png and for bmps, start with default of .t. and then offer facility to the user to toggle transparency.

Regards



G. N. Rao.

Hyderabad, India
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: Image-Zoom possible with NON transparent Images ?
Posted: Mon Apr 18, 2011 10:33 AM
Thank You very much for the Info.

I tested all defined Image-formats with the Zoom-function.
I think, the Results are OK.
Maybe we still need a Image-CONVERT-function ?

1. BMP
Alpha-channel is shown.
A transparent with no Alphashannel, shows the used Color for transparent.
That is OK, because the User can test the used original Background-color.
The browser shows a transparent BMP.

2. PNG, GIF, TIF and TGA
shows Zoom transparent

3. JPG
OK

4. PCX
Transparent ?



5. ICO
The only Problem :
Icons are transparent, but doesn't show it with Zoom ( black Background )
Returns .F. with lAlpha := HasAlpha( hBmp )
Maybe possible, to show a ICO transparent with a Dialog ?



My Test using a external Viewer ( same Results ) :
With xBrowse, I can show both BMP-backgrounds for 32case.
Inside the Browser transparent and with Zoom the original Background.



Best Regards
Uwe :-)
Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Image-Zoom possible with NON transparent Images ?
Posted: Mon Apr 18, 2011 10:31 PM
Mr Uwe

I suggest you do not use Zoom. Instead use ResizeImg().
example:
Code (fw): Select all Collapse
   hBmp     := oImage:hBitmap
   oImage:hBitmap := ResizeImg( hBmp, nW, nH )
   DeleteObject( hBmp )
Regards



G. N. Rao.

Hyderabad, India

Continue the discussion