96 lines
13 KiB
HTML
96 lines
13 KiB
HTML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>The Be Book - System Overview - The Interface Kit</title><link rel="stylesheet" href="be_book.css" type="text/css" media="all" /><link rel="shortcut icon" type="image/vnd.microsoft.icon" href="./images/favicon.ico" /><!--[if IE]>
|
||
<link rel="stylesheet" type="text/css" href="be_book_ie.css" />
|
||
<![endif]--><meta name="generator" content="DocBook XSL Stylesheets V1.73.2" /><meta name="keywords" content="Access, BeOS, BeBook, API" /><link rel="start" href="index.html" title="The Be Book" /><link rel="up" href="TheInterfaceKit_Overview.html" title="The Interface Kit" /><link rel="prev" href="BAlert_Overview.html" title="BAlert" /><link rel="next" href="BBox_Overview.html" title="BBox" /></head><body><div id="header"><div id="headerT"><div id="headerTL"><a accesskey="p" href="BAlert_Overview.html" title="BAlert"><img src="./images/navigation/prev.png" alt="Prev" /></a> <a accesskey="u" href="TheInterfaceKit_Overview.html" title="The Interface Kit"><img src="./images/navigation/up.png" alt="Up" /></a> <a accesskey="n" href="BBox_Overview.html" title="BBox"><img src="./images/navigation/next.png" alt="Next" /></a></div><div id="headerTR"><div id="navigpeople"><a href="http://www.haiku-os.org"><img src="./images/People_24.png" alt="haiku-os.org" title="Visit The Haiku Website" /></a></div><div class="navighome" title="Home"><a accesskey="h" href="index.html"><img src="./images/navigation/home.png" alt="Home" /></a></div><div class="navigboxed" id="navigindex"><a accesskey="i" href="ClassIndex.html" title="Index">I</a></div><div class="navigboxed" id="naviglang" title="English">en</div></div><div id="headerTC">The Be Book - System Overview - The Interface Kit</div></div><div id="headerB">Prev: <a href="BAlert_Overview.html">BAlert</a> Up: <a href="TheInterfaceKit_Overview.html">The Interface Kit</a> Next: <a href="BBox_Overview.html">BBox</a></div><hr /></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><div xmlns:d="http://docbook.org/ns/docbook"><h2 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BBitmap_Overview"></a>BBitmap</h2></div></div></div><a id="id546631" class="indexterm"></a><p>
|
||
A <a class="link" href="BBitmap.html" title="BBitmap"><code class="classname">BBitmap</code></a>
|
||
describes a rectangular image as a two-dimensional array of
|
||
pixel data (or bitmap). The <a class="link" href="BBitmap.html" title="BBitmap"><code class="classname">BBitmap</code></a>
|
||
class lets you create a bitmap by
|
||
specifying raw pixel data (through the
|
||
<a class="link" href="BBitmap.html#BBitmap_Bits" title="Bits()"><code class="methodname">Bits()</code></a> and
|
||
<a class="link" href="BBitmap.html#BBitmap_SetBits" title="SetBits()"><code class="methodname">SetBits()</code></a> functions),
|
||
or you can add a
|
||
<a class="link" href="BView.html" title="BView"><code class="classname">BView</code></a> to your
|
||
<a class="link" href="BBitmap.html" title="BBitmap"><code class="classname">BBitmap</code></a> and use the view's drawing
|
||
operations (
|
||
<a class="link" href="BView.html#BView_FillRect"><code class="methodname">FillRect()</code></a>,
|
||
<a class="link" href="BView.html#BView_StrokeLine" title="StrokeLine()"><code class="methodname">StrokeLine()</code></a>, etc) to draw into the
|
||
<a class="link" href="BBitmap.html" title="BBitmap"><code class="classname">BBitmap</code></a>
|
||
object (see
|
||
"<a class="link" href="BBitmap_Overview.html#BBitmap_Overview_Using_A_View" title="Using a View to Draw into a Bitmap">Using a View to Draw into a Bitmap</a>", below).
|
||
</p><p>
|
||
The <a class="link" href="BBitmap.html" title="BBitmap"><code class="classname">BBitmap</code></a>
|
||
class doesn't provide a way to actually display bitmap data.
|
||
Displaying a bitmap is the task of
|
||
<a class="link" href="BView.html" title="BView"><code class="classname">BView</code></a> functions such as
|
||
<a class="link" href="BView.html#BView_DrawBitmap" title="DrawBitmap(), DrawBitmapAsync()"><code class="methodname">DrawBitmap()</code></a>.
|
||
</p><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><hr /><div xmlns:d="http://docbook.org/ns/docbook"><h3 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BBitmap_Overview_Bitmap_Data"></a>Bitmap Data</h3></div></div></div><p>
|
||
A bitmap records the color values of every pixel within a rectangular
|
||
area. The data is specified in rows, beginning with the top row of pixels
|
||
in the image and working downward to the bottom row. Each row is aligned
|
||
on a long word boundary.
|
||
</p><p>
|
||
When you construct a <a class="link" href="BBitmap.html" title="BBitmap"><code class="classname">BBitmap</code></a>
|
||
object, you give it a bounds rectangle
|
||
(integer coordinates only!) and a color space. For example, this code
|
||
</p><pre class="programlisting example cpp"><span class="type">BBitmap*</span> <code class="varname">image</code> = new <code class="classname">BBitmap</code>(<code class="classname">BRect</code>(0.0, 0.0, 79.0, 39.0),
|
||
<code class="constant">B_CMAP8</code>);</pre><p>
|
||
constructs a 40 x 80 bitmap of 8-bit color data.
|
||
</p><p>
|
||
The data in a <a class="link" href="BBitmap.html" title="BBitmap"><code class="classname">BBitmap</code></a>
|
||
object isn't initialized—a <a class="link" href="BBitmap.html" title="BBitmap"><code class="classname">BBitmap</code></a> has no
|
||
default background color. When you set the bitmap's data (however you set
|
||
it) you must "paint" every pixel within the bitmap's bounds rectangle.
|
||
</p></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><hr /><div xmlns:d="http://docbook.org/ns/docbook"><h3 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BBitmap_Overview_Using_A_View"></a>Using a View to Draw into a Bitmap</h3></div></div></div><p>
|
||
If you're going to use a view to draw into your bitmap, you must tell the
|
||
<a class="link" href="BBitmap.html" title="BBitmap"><code class="classname">BBitmap</code></a>
|
||
constructor by setting the third argument to <code class="constant">true</code>:
|
||
</p><pre class="programlisting example cpp"><span class="type">BBitmap *</span><code class="varname">image</code> = new <code class="classname">BBitmap</code>(<code class="classname">BRect</code>(...), <code class="constant">B_CMAP8</code>, <code class="constant">true</code>);</pre><p>
|
||
You then add the view to the bitmap (you don't have to do anything
|
||
special when constructing the <a class="link" href="BView.html" title="BView"><code class="classname">BView</code></a>):
|
||
</p><pre class="programlisting example cpp"><code class="varname">bitmap</code>-><code class="methodname">AddChild</code>(<code class="varname">view</code>);</pre><p>
|
||
When the view draws, the drawing operations are rendered into the bitmap.
|
||
Note that you must explicitly tell the <a class="link" href="BView.html" title="BView"><code class="classname">BView</code></a>):
|
||
to draw—the <a class="link" href="BView.html" title="BView"><code class="classname">BView</code></a>s
|
||
that you use to draw into a <a class="link" href="BBitmap.html" title="BBitmap"><code class="classname">BBitmap</code></a> aren't part of the user interface, so
|
||
they won't receive user event messages. When you're done drawing, you
|
||
should call <a class="link" href="BView.html" title="BView"><code class="classname">BView</code></a>'s
|
||
<a class="link" href="BView.html#BView_Sync"><code class="methodname">Sync()</code></a> function to make sure the drawing has all
|
||
been performed. If the bitmap that you've created is static—if it
|
||
doesn't need to change after you've drawn into it—you can throw
|
||
away the <a class="link" href="BView.html" title="BView"><code class="classname">BView</code></a> that you used create the bitmap data.
|
||
</p><p>
|
||
A <a class="link" href="BBitmap.html" title="BBitmap"><code class="classname">BBitmap</code></a>
|
||
can contain more than one <a class="link" href="BView.html" title="BView"><code class="classname">BView</code></a>—it
|
||
can act as the root of an entire view hierarchy. The
|
||
<a class="link" href="BBitmap.html" title="BBitmap"><code class="classname">BBitmap</code></a>
|
||
class defines a number of
|
||
<a class="link" href="BWindow.html" title="BWindow"><code class="classname">BWindow</code></a>-like
|
||
functions—<a class="link" href="BBitmap.html#BBitmap_AddChild" title="AddChild()"><code class="methodname">AddChild()</code></a>,
|
||
<a class="link" href="BBitmap.html#BBitmap_FindView" title="FindView()"><code class="methodname">FindView()</code></a>,
|
||
<a class="link" href="BBitmap.html#BBitmap_ChildAt" title="ChildAt(), CountChildren()"><code class="methodname">ChildAt()</code></a>, and so
|
||
on—to help you create and manage the hierarchy.
|
||
</p></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><hr /><div xmlns:d="http://docbook.org/ns/docbook"><h3 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BBitmap_Overview_Transparency"></a>Transparency</h3></div></div></div><p>
|
||
Color bitmaps can have transparent pixels. When the bitmap is imaged in a
|
||
drawing mode other than <code class="constant">B_OP_COPY</code>, its transparent pixels won't be
|
||
transferred to the destination view. The destination image will show
|
||
through wherever the bitmap is transparent.
|
||
</p><p>
|
||
To introduce transparency into a <code class="constant">B_CMAP8</code> bitmap, a pixel can be assigned
|
||
one of the following values, as appropriate for the bitmap's color space.
|
||
</p><table class="variablelist constants"><thead><tr><th>Constant</th><th>Description</th></tr></thead><tbody><tr><td><p><span class="term"><code class="constant">B_TRANSPARENT_MAGIC_CMAP8</code></span></p></td><td><p>8-bit indexed color transparent pixel.</p></td></tr><tr><td><p><span class="term"><code class="constant">B_TRANSPARENT_MAGIC_RGBA15</code></span></p></td><td><p>15-bit transparent pixel.</p></td></tr><tr><td><p><span class="term"><code class="constant">B_TRANSPARENT_MAGIC_RGBA15_BIG</code></span></p></td><td><p>15-bit transparent pixel, big-endian.</p></td></tr><tr><td><p><span class="term"><code class="constant">B_TRANSPARENT_MAGIC_RGBA32</code></span></p></td><td><p>32-bit transparent pixel.</p></td></tr><tr><td><p><span class="term"><code class="constant">B_TRANSPARENT_MAGIC_RGBA32_BIG</code></span></p></td><td><p>32-bit transparent pixel, big-endian.</p></td></tr></tbody></table><p>
|
||
Opaque pixels should have an alpha value of 255 for 8-bit alpha channels
|
||
or 1 for 1-bit alpha channels; values of 0 indicate 100% transparent
|
||
pixels. Values in between (for 8-bit alpha channels) represent varying
|
||
degrees of transparency.
|
||
</p><p>
|
||
Transparency is covered in more detail under
|
||
"<a class="link" href="TheInterfaceKit_Drawing.html#TheInterfaceKit_Drawing_Drawing_Modes" title="Drawing Modes">Drawing Modes</a>".
|
||
</p><p>
|
||
See also:
|
||
<a class="link" href="TheInterfaceKit_Functions.html#system_colors" title="system_colors()"><code class="function">system_colors()</code></a>
|
||
</p></div></div><div id="footer"><hr /><div id="footerT">Prev: <a href="BAlert_Overview.html">BAlert</a> Up: <a href="TheInterfaceKit_Overview.html">The Interface Kit</a> Next: <a href="BBox_Overview.html">BBox</a> </div><div id="footerB"><div id="footerBL"><a href="BAlert_Overview.html" title="BAlert"><img src="./images/navigation/prev.png" alt="Prev" /></a> <a href="TheInterfaceKit_Overview.html" title="The Interface Kit"><img src="./images/navigation/up.png" alt="Up" /></a> <a href="BBox_Overview.html" title="BBox"><img src="./images/navigation/next.png" alt="Next" /></a></div><div id="footerBR"><div><a href="http://www.haiku-os.org"><img src="./images/People_24.png" alt="haiku-os.org" title="Visit The Haiku Website" /></a></div><div class="navighome" title="Home"><a accesskey="h" href="index.html"><img src="./images/navigation/home.png" alt="Home" /></a></div></div><div id="footerBC"><a href="http://www.access-company.com/home.html" title="ACCESS Co."><img alt="Access Company" src="./images/access_logo.png" /></a></div></div></div><div id="licenseFooter"><div id="licenseFooterBL"><a rel="license" href="http://creativecommons.org/licenses/by-nc-nd/3.0/" title="Creative Commons License"><img alt="Creative Commons License" style="border-width:0" src="https://licensebuttons.net/l/by-nc-nd/3.0/88x31.png" /></a></div><div id="licenseFooterBR"><a href="./LegalNotice.html">Legal Notice</a></div><div id="licenseFooterBC"><span id="licenseText">This work is licensed under a
|
||
<a rel="license" href="http://creativecommons.org/licenses/by-nc-nd/3.0/">Creative
|
||
Commons Attribution-Non commercial-No Derivative Works 3.0 License</a>.</span></div></div></body></html>
|