Hi.
I think I saw a solution for this, but I'm unable to find it. So if anyone saw it, please send me the link to the post.
Is there a way to paint a background, image on a window and tell it to paint with a some % of transparency, so the client didn't bother to make the image partialy transparent.
Something like.. Paint_image(cFile, 0.3) // 0.3 being 30%
Thanks in advance.
Froom Chile
Adolfo
Show Image with % of transparency
Show Image with % of transparency

http://www.xdata.cl - Desarrollo Inteligente
----------
Asus TUF F15, 32GB Ram, 2 * 1 TB NVME M.2, GTX 1650
Re: Show Image with % of transparency
Adolfo,
with the Imagetools, You can create a background-image
with a included transparent logo :
( there will be a update in a short time )
to draw a logo on any other control like a window or dialog :
( be sure, it is a ALPHABLENDED IMAGE )
#include "FiveWin.ch"
function Main()
local oWnd, oBmp, oBrush
DEFINE BITMAP oBmp FILENAME "..\bitmaps\AlphaBmp\Trash.bmp"
DEFINE BRUSH oBrush FILENAME "..\bitmaps\backgrnd\paper2.bmp"
DEFINE WINDOW oWnd TITLE "FWH 8.05 Transparencies" ;
COLOR 0, "N/W" BRUSH oBrush
ACTIVATE WINDOW oWnd ;
ON PAINT ABPaint( hDC, 10, 10, oBmp:hBitmap, 220 ) // 0-255 transparency level
oBrush:End()
oBmp:End()
return nil
To create a MERGED image ( can include different logos with different sizes and transp.-levels ):
1. Select a main-image with the button < Load >
2. from the combobox select style : Transp.logo
3. select a alpha-logo ( You can add different logos during the painting )
4. from a combobox select the transparent level
5. from a combobox, You can define a resize-factor
6. with a left mouseclick You can place the logo on the main-image
7. use UNDO, if You don't like the position
8. at the end use the button < export >, to create the image
-- You can define the Export-filename ( saved in subdirectory EXPORT )
9. the button < show > opens a preview of the result

best regards
Uwe
with the Imagetools, You can create a background-image
with a included transparent logo :
( there will be a update in a short time )
to draw a logo on any other control like a window or dialog :
( be sure, it is a ALPHABLENDED IMAGE )
#include "FiveWin.ch"
function Main()
local oWnd, oBmp, oBrush
DEFINE BITMAP oBmp FILENAME "..\bitmaps\AlphaBmp\Trash.bmp"
DEFINE BRUSH oBrush FILENAME "..\bitmaps\backgrnd\paper2.bmp"
DEFINE WINDOW oWnd TITLE "FWH 8.05 Transparencies" ;
COLOR 0, "N/W" BRUSH oBrush
ACTIVATE WINDOW oWnd ;
ON PAINT ABPaint( hDC, 10, 10, oBmp:hBitmap, 220 ) // 0-255 transparency level
oBrush:End()
oBmp:End()
return nil
To create a MERGED image ( can include different logos with different sizes and transp.-levels ):
1. Select a main-image with the button < Load >
2. from the combobox select style : Transp.logo
3. select a alpha-logo ( You can add different logos during the painting )
4. from a combobox select the transparent level
5. from a combobox, You can define a resize-factor
6. with a left mouseclick You can place the logo on the main-image
7. use UNDO, if You don't like the position
8. at the end use the button < export >, to create the image
-- You can define the Export-filename ( saved in subdirectory EXPORT )
9. the button < show > opens a preview of the result

Code: Select all | Expand
// -----------TRANSPARENT LOGO ----------------------
STATIC FUNCTION DRAW_LOGO( hMemDC )
LOCAL oImg0, oImg, nLWidth, nLHeight
// hMemDC = DC of the main-image
IF FILE ( cImagepath + ALLTRIM(cTLogo) )
// get the size with a defined resize-factor
DEFINE IMAGE oImg0 FILENAME cImagepath + ALLTRIM(cTLogo)
nLWidth := oImg0:nWidth * ( nLIResize / 100 )
nLHeight := oImg0:nHeight * ( nLIResize / 100 )
oImg0:End()
// load the image
oImg0 := FILoadImg( cImagepath + cTLogo )
// resize with a given resize-factor
oImg := ResizeImg( oImg0, nLWidth, nLHeight )
// nWFactor and nHFactor = display-size-factor of the main-image
IF nWFactor > 1 .and. nHFactor > 1
ABPaint( hMemDC, aPoints[1][2], aPoints[1][1], oImg, nTrLevel )
ELSE
IF nWFactor < nHFactor .OR. nWFactor < 1 .and. nHFactor > 1
ABPaint( hMemDC, aPoints[1][2] / nWFactor, aPoints[1][1] / nWFactor, oImg, nTrLevel )
ENDIF
IF nWFactor > nHFactor .OR. nWFactor > 1 .and. nHFactor < 1
ABPaint( hMemDC, aPoints[1][2] / nHFactor, aPoints[1][1] / nHFactor, oImg, nTrLevel )
ENDIF
ENDIF
ELSE
MsgAlert( "File : " + ALLTRIM(cTLogo) + CRLF + ;
"does not exist" + CRLF + ;
"to show Image !", "ERROR" )
ENDIF
RETURN( NIL )
best regards
Uwe

Last edited by ukoenig on Mon Jun 02, 2014 8:08 pm, edited 1 time in total.
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.
i work with FW.
If you have any questions about special functions, maybe i can help.
Re: Show Image with % of transparency
Uwe,
Thansk again for your help, I appreciate it a lot.
Let me explain something to you, I don't know, there's no way I can manage the type of images my client is going to use. I'm pretty sure they won't be AlphaBlended, since they are no "power users", so I guess they will use any picture taken from a camera o some screen captures.
With that on mind, your routine will not help me.
So, is there a way to paint any jpg with some degree of transparency?
Thanks in advance
From Chile
Adolfo
Thansk again for your help, I appreciate it a lot.
Let me explain something to you, I don't know, there's no way I can manage the type of images my client is going to use. I'm pretty sure they won't be AlphaBlended, since they are no "power users", so I guess they will use any picture taken from a camera o some screen captures.
With that on mind, your routine will not help me.
So, is there a way to paint any jpg with some degree of transparency?
Thanks in advance
From Chile
Adolfo

http://www.xdata.cl - Desarrollo Inteligente
----------
Asus TUF F15, 32GB Ram, 2 * 1 TB NVME M.2, GTX 1650
Re: Show Image with % of transparency
Adolfo,
This image shows a JPG saved as a BMP with ALPHACHANNEL and displayed with different
transparent-levels. NO transparent-areas are defined.
You MUST convert a image, to add / define transparent levels if not included.
I can try to create a function from inside a program, to convert a image and adding the needed Alphachannel.
Sample : Olga.JPG loaded with < PIXELFORMER > and saved as BMP ( or PNG ) with alphachannel.

best regards
Uwe
This image shows a JPG saved as a BMP with ALPHACHANNEL and displayed with different
transparent-levels. NO transparent-areas are defined.
You MUST convert a image, to add / define transparent levels if not included.
I can try to create a function from inside a program, to convert a image and adding the needed Alphachannel.
Sample : Olga.JPG loaded with < PIXELFORMER > and saved as BMP ( or PNG ) with alphachannel.

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.
i work with FW.
If you have any questions about special functions, maybe i can help.