Image-Zoom possible with NON transparent Images ?

Image-Zoom possible with NON transparent Images ?

Postby ukoenig » Sat Apr 16, 2011 5: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.

Image

@ 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 ).

Image

Added Alphachannel to a < normal BMP > it works.

Image

In Class Bitmap, maybe something is missing ?
Code: Select all  Expand view

...
...
         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.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: Image-Zoom possible with NON transparent Images ?

Postby nageswaragunupudi » 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
User avatar
nageswaragunupudi
 
Posts: 10489
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Image-Zoom possible with NON transparent Images ?

Postby ukoenig » 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 ?

Image

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 ?

Image

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.

Image

Best Regards
Uwe :lol:
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.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: Image-Zoom possible with NON transparent Images ?

Postby nageswaragunupudi » Mon Apr 18, 2011 10:31 pm

Mr Uwe

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

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10489
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 29 guests