Symbian3/SDK/Source/GUID-294E84BB-65D0-5275-848E-1960B201A371.dita
changeset 0 89d6a7a84779
equal deleted inserted replaced
-1:000000000000 0:89d6a7a84779
       
     1 <?xml version="1.0" encoding="utf-8"?>
       
     2 <!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. -->
       
     3 <!-- This component and the accompanying materials are made available under the terms of the License 
       
     4 "Eclipse Public License v1.0" which accompanies this distribution, 
       
     5 and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". -->
       
     6 <!-- Initial Contributors:
       
     7     Nokia Corporation - initial contribution.
       
     8 Contributors: 
       
     9 -->
       
    10 <!DOCTYPE concept
       
    11   PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
       
    12 <concept xml:lang="en" id="GUID-294E84BB-65D0-5275-848E-1960B201A371"><title>Creating and Drawing to an Off-Screen Bitmap</title><prolog><metadata><keywords/></metadata></prolog><conbody><p>This topic provides an example that shows the creation of a bitmap, the creation of an off-screen graphics device and graphics context for it, and the use of that graphics context to draw to the bitmap. Once a graphics context has been established for the bitmap, any of the GDI drawing functions can be used on the bitmap, as if it were the more common graphics context—the screen. </p> <codeblock id="GUID-E7A1651B-4F87-5156-9CDE-F8205323DB8E" xml:space="preserve">// Create a bitmap to be used off-screen.
       
    13 CFbsBitmap* offScreenBitmap = new (ELeave) CFbsBitmap();
       
    14 CleanupStack::PushL(offScreenBitmap);
       
    15 User::LeaveIfError(offScreenBitmap-&gt;Create(TSize(100,100),EColor256));
       
    16      
       
    17 // Create an off-screen device and context.
       
    18 CGraphicsContext* bitmapContext=NULL;
       
    19 CFbsBitmapDevice* bitmapDevice = CFbsBitmapDevice::NewL(offScreenBitmap);
       
    20 CleanupStack::PushL(bitmapDevice);
       
    21 User::LeaveIfError(bitmapDevice-&gt;CreateContext(bitmapContext));
       
    22 CleanupStack::PushL(bitmapContext);
       
    23      
       
    24 // Draw something on the bitmap.
       
    25 TRect rect(0,0,100,100);
       
    26 bitmapContext-&gt;SetBrushColor(KRgbRed);
       
    27 bitmapContext-&gt;SetBrushStyle(CGraphicsContext::ESolidBrush);
       
    28 bitmapContext-&gt;DrawRect(rect); // a filled red rectangle
       
    29      
       
    30 // Now do what you want with it, such as blitting to the screen.
       
    31 gc.BitBlt(TPoint(20,20),offScreenBitmap);
       
    32     
       
    33 // Cleanup.
       
    34 CleanupStack::PopAndDestroy(3);
       
    35 ...</codeblock> </conbody><related-links><link href="GUID-AFE8A9CC-E026-5396-8E0C-616338B5F5C3.dita"><linktext>BitGDI Tutorials</linktext> </link> <link href="GUID-EAAD1719-C02C-5705-A5C3-993E36441BE6.dita"><linktext>BitGDI Component</linktext> </link> </related-links></concept>