Initial contribution of Documentation_content according to Feature bug 1266 bug 1268 bug 1269 bug 1270 bug 1372 bug 1374 bug 1375 bug 1379 bug 1380 bug 1381 bug 1382 bug 1383 bug 1385
<?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><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><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><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-5FAF3401-9EC6-3411-9AB3-BBDB4A448C65.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>
</related-links></concept>