2007Year,AlexIn 《Compelling UI's in netcf anybody?This article describesWindows Mobile 5How to use on the platformAlphablendMake a cool transparent image interface. Recent webcast《24 hours of Windows Mobile Application Development: Creating compelling and attractive UIS for Windows Mobile applicationsHe tells about the currentWindows MobileTrend of interface design, which also involves alpha blendingAnd Alpha ChannelTechnology. These two concepts are explained below.
In the encyclopedia Wiki We can find this Alpha compositing . In computer graphics, Alpha compositing It is a technology that combines images and backgrounds to create partial transparency. Alpha Channel The earliest is from A. R. Smith In 20 Century 70 Proposed by the time, the final Thomas Porter And Tom Duff In 1984 Years of development Maturity . To put it simply, the color of a traditional pixel is used RGB In Alpha Channel The fourth parameter needs to be added, as shown in figure (0.0, 0.5, 0.0, 0.5) , The preceding three parameters" 0.0, 0.5, 0.0 "Indicates RGB And the fourth Parameter 0.5 Indicates Alpha Value . Therefore Thomas Porter And Tom Duff In the paper, they use Alpha Value, which defines 5 Operation (Over, in, out, atop, XOR) For more information about the effect, see 1 :
Figure 1:5Operation (image excerptAlpha compositing)
CurrentlyAlpha blendingOperating System/GUIIncludes the following types:
- Mac OS X
- Windows 2000, XP, Server 2003, Windows CE, Vista and Windows 7
- the xrender extension to the X Window System (this includes des modern Linux systems)
- risc OS adjust
- QNX neutrino
- Plan 9
- inferno
- amigaos 4.1
- BEOs, zenand haiku
- syllable
- morphos
Windows Mobile 5.0Now the Platform SupportsAlpha blending. InHttp://code.msdn.microsoft.com/uiframeworkThis courseCode, We can see that in the project, he usedP/invoke:
Code
[Dllimport ( " Coredll. dll " )]
Extern Public StaticInt32 alphablend (intptr hdcdest, int32 xdest, int32 ydest, int32 cxdest, int32 cydest, intptr hdcsrc, int32 xsrc, int32 ysrc, int32 cxsrc, int32 cysrc, blendfunction );
EncapsulatedDrawalphaThis method:
Code
Public Static Void Drawalpha ( This Graphics GX, bitmap image, Byte Transparency, Int X, Int Y)
{
Using(Graphics gxsrc=Graphics. fromimage (image ))
{
Intptr hdcdst=GX. gethdc ();
Intptr hdcsrc=Gxsrc. gethdc ();
Blendfunction= NewBlendfunction ();
Blendfunction. blendop = ( Byte ) Blendoperation. ac_src_over; // Only supported blend operation
Blendfunction. blendflags = ( Byte ) Blendflags. zero; // Documentation says put 0 here
Blendfunction. sourceconstantalpha = Transparency; // Constant Alpha factor
Blendfunction. alphaformat = ( Byte ) 0 ; // Don't look for per pixel alpha
Platformapis. alphablend (hdcdst, X, Y, image. Width, image. height,
Hdcsrc,0,0, Image. Width, image. Height, blendfunction );
GX. releasehdc (hdcdst ); // Required cleanup to gethdc ()
Gxsrc. releasehdc (hdcsrc ); // Required cleanup to gethdc ()
}
}
Finally, the author gives thisMethod Application, display the weather UI on the desktopAnd ImageSlideShow. At the same time, you can use the following code to hide the title barAnd the application is displayed in full screen.Program.
Code
// Don't show title bar and allocate the full screen
This . Formborderstyle = Formborderstyle. None;
This. Windowstate=Formwindowstate. maximized;
In addition, the author also gives the processing of the color changes of the button float and press status, as well as the textFor processing text embedding, you can download it for reference.
The final display effect is as follows: 2As shown in:
Figure 2: Program UIEffect
Yes locationComparison between normal status and Press:
Figure 3: Different Effects of buttons
Reference link:
Alex:Compelling UI's in netcf anybody?"
Msdn:Alphablend
Webcast:24 hours of Windows Mobile Application Development: Creating compelling and attractive UIS for Windows Mobile applications"
Wiki:Alpha compositing