Thread: [Dev-C++] trying to use AlphaBlend
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Wobien <roo...@pl...> - 2007-11-05 13:16:10
|
Hi,
I want to display bitmaps that have transparent and semi-transparent pixels
in a windows program.
Searching the mdsn information on the web I found the AlphaBlend function,
that promises exactly what I wanted, so I gave it a try.
>From MSDN topic AlphaBlend:
"
Requirements
Windows NT/2000/XP/Vista: Included in Windows 2000 and later.
Windows 95/98/Me: Included in Windows 98 and later.
Header: Declared in Wingdi.h; include Windows.h.
Library: Included as a resource in Msimg32.dll.
"
To start with, I copied an example from the mdsn site into a cpp file in my
project.
I am using windows XP, I included Windows.h, and I added libmsimg32.a to the
command line options for the linker in the project options and I tried to
compile.(I copied part of my cpp-file below)
The result was an AlphaBlend not declared errror.
I checked the Windows.h and Wingdi.h files:
>From windows.h:
"
#if !(defined NOGDI || defined _WINGDI_H)
#include <wingdi.h>
#endif
"
>From Wingni.h:
"
#if (WINVER >= 0x0500)
WINGDIAPI BOOL WINAPI
AlphaBlend(HDC,int,int,int,int,HDC,int,int,int,int,BLENDFUNCTION);
WINGDIAPI BOOL WINAPI GradientFill(HDC,PTRIVERTEX,ULONG,PVOID,ULONG,ULONG);
WINGDIAPI BOOL WINAPI
TransparentBlt(HDC,int,int,int,int,HDC,int,int,int,int,UINT);
#endif
"
It looks as if the preprocessor skips the declaration of AlphaBlend because
WINVER<0x500.
Do I have to inform the preprocessor about the windows version I am using?
And if so, how do I do that (I tried to find the answer in the on-line
manual on the gcc site, but didn't find anything usefull)?
from my cpp-file:
#include <windows.h>
.
.
.
if (!AlphaBlend(hdcwnd, ulWindowWidth/5, ulWindowHeight/5,
ulBitmapWidth, ulBitmapHeight,
hdc, 0, 0, ulBitmapWidth, ulBitmapHeight, bf))
return; // alpha blend failed
.
.
Thanks for your attention,
Wobien
|
|
From: Per W. <pw...@ia...> - 2007-11-05 13:30:07
|
MDSN? Do you mean Micro-Developers Soft Network? :) I think you mean MSDN. Yes, you have to define the WINVER define, to set the minimum version of Windows that your application requires. Microsoft has specifically added the WINVER define to "protect" a developer from by mistake using a Windows API that blocks the application from working on older OS. You define WINVER in the same way that you devine any other preprocesor data - for example by opening the project settings and add a WINVER=xx. /pwm On Mon, 5 Nov 2007, Wobien wrote: > Hi, > > I want to display bitmaps that have transparent and semi-transparent pixels > in a windows program. > > Searching the mdsn information on the web I found the AlphaBlend function, > that promises exactly what I wanted, so I gave it a try. > > > >From MSDN topic AlphaBlend: > " > Requirements > Windows NT/2000/XP/Vista: Included in Windows 2000 and later. > Windows 95/98/Me: Included in Windows 98 and later. > Header: Declared in Wingdi.h; include Windows.h. > Library: Included as a resource in Msimg32.dll. > " > > To start with, I copied an example from the mdsn site into a cpp file in my > project. > I am using windows XP, I included Windows.h, and I added libmsimg32.a to the > command line options for the linker in the project options and I tried to > compile.(I copied part of my cpp-file below) > The result was an AlphaBlend not declared errror. > > I checked the Windows.h and Wingdi.h files: > > >From windows.h: > " > #if !(defined NOGDI || defined _WINGDI_H) > #include <wingdi.h> > #endif > " > > >From Wingni.h: > " > #if (WINVER >= 0x0500) > WINGDIAPI BOOL WINAPI > AlphaBlend(HDC,int,int,int,int,HDC,int,int,int,int,BLENDFUNCTION); > WINGDIAPI BOOL WINAPI GradientFill(HDC,PTRIVERTEX,ULONG,PVOID,ULONG,ULONG); > WINGDIAPI BOOL WINAPI > TransparentBlt(HDC,int,int,int,int,HDC,int,int,int,int,UINT); > #endif > " > > It looks as if the preprocessor skips the declaration of AlphaBlend because > WINVER<0x500. > Do I have to inform the preprocessor about the windows version I am using? > And if so, how do I do that (I tried to find the answer in the on-line > manual on the gcc site, but didn't find anything usefull)? > > from my cpp-file: > > #include <windows.h> > . > . > . > if (!AlphaBlend(hdcwnd, ulWindowWidth/5, ulWindowHeight/5, > ulBitmapWidth, ulBitmapHeight, > hdc, 0, 0, ulBitmapWidth, ulBitmapHeight, bf)) > return; // alpha blend failed > . > . > > Thanks for your attention, > > Wobien > > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Splunk Inc. > Still grepping through log files to find problems? Stop. > Now Search log events and configuration files using AJAX and a browser. > Download your FREE copy of Splunk now >> http://get.splunk.com/ > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > |
|
From: Wobien <roo...@pl...> - 2007-11-05 17:08:35
|
Hello Per, Great! I have the example from MSDN working now, so I can try changing it to my needs. Thanks a lot for your prompt reply! Wobien ----- Original Message ----- From: "Per Westermark" <pw...@ia...> To: "Wobien" <roo...@pl...> Cc: "dev-cpp-users-list" <dev...@li...> Sent: Monday, November 05, 2007 2:29 PM Subject: Re: [Dev-C++] trying to use AlphaBlend > MDSN? > > Do you mean Micro-Developers Soft Network? :) > > I think you mean MSDN. > > Yes, you have to define the WINVER define, to set the minimum version of > Windows that your application requires. > > Microsoft has specifically added the WINVER define to "protect" a > developer from by mistake using a Windows API that blocks the application > from working on older OS. > > You define WINVER in the same way that you devine any other preprocesor > data - for example by opening the project settings and add a WINVER=xx. > > /pwm > > On Mon, 5 Nov 2007, Wobien wrote: > >> Hi, >> >> I want to display bitmaps that have transparent and semi-transparent >> pixels >> in a windows program. >> >> Searching the mdsn information on the web I found the AlphaBlend >> function, >> that promises exactly what I wanted, so I gave it a try. >> >> >> >From MSDN topic AlphaBlend: >> " >> Requirements >> Windows NT/2000/XP/Vista: Included in Windows 2000 and later. >> Windows 95/98/Me: Included in Windows 98 and later. >> Header: Declared in Wingdi.h; include Windows.h. >> Library: Included as a resource in Msimg32.dll. >> " >> >> To start with, I copied an example from the mdsn site into a cpp file in >> my >> project. >> I am using windows XP, I included Windows.h, and I added libmsimg32.a to >> the >> command line options for the linker in the project options and I tried to >> compile.(I copied part of my cpp-file below) >> The result was an AlphaBlend not declared errror. >> >> I checked the Windows.h and Wingdi.h files: >> >> >From windows.h: >> " >> #if !(defined NOGDI || defined _WINGDI_H) >> #include <wingdi.h> >> #endif >> " >> >> >From Wingni.h: >> " >> #if (WINVER >= 0x0500) >> WINGDIAPI BOOL WINAPI >> AlphaBlend(HDC,int,int,int,int,HDC,int,int,int,int,BLENDFUNCTION); >> WINGDIAPI BOOL WINAPI >> GradientFill(HDC,PTRIVERTEX,ULONG,PVOID,ULONG,ULONG); >> WINGDIAPI BOOL WINAPI >> TransparentBlt(HDC,int,int,int,int,HDC,int,int,int,int,UINT); >> #endif >> " >> >> It looks as if the preprocessor skips the declaration of AlphaBlend >> because >> WINVER<0x500. >> Do I have to inform the preprocessor about the windows version I am >> using? >> And if so, how do I do that (I tried to find the answer in the on-line >> manual on the gcc site, but didn't find anything usefull)? >> >> from my cpp-file: >> >> #include <windows.h> >> . >> . >> . >> if (!AlphaBlend(hdcwnd, ulWindowWidth/5, ulWindowHeight/5, >> ulBitmapWidth, ulBitmapHeight, >> hdc, 0, 0, ulBitmapWidth, ulBitmapHeight, bf)) >> return; // alpha blend failed >> . >> . >> >> Thanks for your attention, >> >> Wobien >> >> >> >> ------------------------------------------------------------------------- >> This SF.net email is sponsored by: Splunk Inc. >> Still grepping through log files to find problems? Stop. >> Now Search log events and configuration files using AJAX and a browser. >> Download your FREE copy of Splunk now >> http://get.splunk.com/ >> _______________________________________________ >> Dev-cpp-users mailing list >> Dev...@li... >> TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm >> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users >> > |