Symbian3/SDK/Source/GUID-02BD38E7-A579-5BD5-9444-4E7C14C7809A.dita
author Dominic Pinkman <dominic.pinkman@nokia.com>
Fri, 11 Jun 2010 15:24:34 +0100
changeset 9 59758314f811
parent 8 ae94777fff8f
permissions -rw-r--r--
Week 23 contribution of PDK documentation content. See release notes for details. Fixes bugs Bug 2714, Bug 462.

<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. -->
<!-- This component and the accompanying materials are made available under the terms of the License 
"Eclipse Public License v1.0" which accompanies this distribution, 
and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". -->
<!-- Initial Contributors:
    Nokia Corporation - initial contribution.
Contributors: 
-->
<!DOCTYPE concept
  PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
<concept id="GUID-02BD38E7-A579-5BD5-9444-4E7C14C7809A" xml:lang="en"><title>Transparent
Windows</title><shortdesc>This topic introduces the window transparency feature, which you
can use to create semi-transparent UI content over other UI content. In ScreenPlay
you can also use transparent windows to create semi-transparent UI content
over external content, such as video and OpenGL ES. For example, in ScreenPlay
you can display a semi-transparent dialog box over an OpenGL ES game. Transparent
windows are implemented using alpha compositing, which means that the transparency
information is embedded within the drawing commands. </shortdesc><prolog><metadata><keywords/></metadata></prolog><conbody>
<p> <i>Note</i>: Semi-transparent UI content over content provided by Direct
Screen Access (DSA) has never been supported and ScreenPlay does not change
this. </p>
<p> <b>Variant</b>: ScreenPlay and non-ScreenPlay. <b>Target audience</b>:
Application developers. </p>
<section id="GUID-7208D287-D0D9-4E19-89F0-87DB9BCE4736"><title>Alpha compositing</title> <p>In
alpha compositing, an alpha channel is used to store opacity information along
with the color values for each pixel. For example, if the color is represented
as RGB values, the pixel values are typically stored as RGBA, where the final
value is the alpha value. This represents the percentage opacity. Like the
RGB values, the alpha value is frequently expressed in the range of 0 (completely
transparent) to 255 (fully opaque). For example, (0, 0, 0, 0) represents fully
transparent black and (255, 255, 255, 127) represents white that has 50% opacity. </p> <p>Each
of the RGB values are multiplied by the alpha percentage to give the opacity
of the pixel. In order to reduce the need for multiplication during the compositing
process, the RGB values are sometimes multiplied by the alpha value before
storage. This is known as <b>premultiplied alpha</b> format. For example,
a premultiplied alpha representation of white that has 50% opacity is (127,
127, 127, 127). </p> </section>
<section id="GUID-ED7D01C9-6B18-4280-B44E-B62ADE9EBA90"><title>Enabling transparency</title> <p>To
enable transparency, call the <xref href="GUID-683603DD-F3D3-3193-BEB3-8236C7DE7F79.dita"><apiname>RWindow::SetTransparencyAlphaChannel()</apiname></xref> method
on the window (which must be an <xref href="GUID-683603DD-F3D3-3193-BEB3-8236C7DE7F79.dita"><apiname>RWindow</apiname></xref> type)
before it is activated. The transparency is then determined by the alpha values
of the content rendered to the window. Typically you set the background to
be fully or partially transparent, as shown in the following example: </p> <codeblock id="GUID-C33B91C2-D83C-5A6D-91A5-AB29B8EF46A0" xml:space="preserve">// Set transparency mode on.
iWindow.SetTransparencyAlphaChannel();
    
// Set the background to be fully transparent black.
iWindow.SetBackgroundColor(TRgb(0,0,0,0)); 
    
// Activate the window.
iWindow.Activate();
    
// Begin drawing to the window.
...  </codeblock></section>
<section id="GUID-66EBABCC-4BF4-4DE8-9AD3-27598F3A0025"><title>Note</title><p>In
earlier versions of the Symbian platform, it was possible to create transparent
windows using a mask and the <xref href="GUID-683603DD-F3D3-3193-BEB3-8236C7DE7F79.dita"><apiname>RWindow</apiname></xref> class's <codeph>SetTransparencyFactor()</codeph>, <codeph>SetTransparencyBitmap()</codeph> and <codeph>SetTransparencyWsBitmap()</codeph> methods. <b>This mechanism
is now deprecated and these methods are no longer functional</b>.</p><p>A
new application and UI framework is planned for Symbian^4 (S^4). In order
for AVKON applications (and clients that draw using <xref href="GUID-0AEE5955-C530-35F1-A904-69183331B294.dita"><apiname>CWindowGc</apiname></xref>)
to work correctly on this new framework, the main view must be opaque. See <xref href="GUID-29272C8D-A0F6-4861-90FB-D1637D0D8CD8.dita">How will the New Application
Architecture Affect my Applications?</xref> for more information.</p> </section>
</conbody><related-links>
<link href="GUID-99AE1D62-571A-5A63-B472-C0FBC0861F52.dita"><linktext>Window Types</linktext>
</link>
<link href="GUID-29272C8D-A0F6-4861-90FB-D1637D0D8CD8.dita"><linktext>How will
the New Application Architecture Affect my Applications?</linktext></link>
<link href="GUID-96E46D0E-1CE3-58B4-AE99-6B2E622ADAF9.dita"><linktext>Drawing transparent
windows example</linktext></link>
</related-links></concept>