File: Load.html

package info (click to toggle)
openlayer 2.1-2.1
  • links: PTS
  • area: main
  • in suites: bullseye, buster, stretch
  • size: 3,392 kB
  • ctags: 2,317
  • sloc: ansic: 10,433; cpp: 9,890; xml: 109; makefile: 90; sh: 36
file content (48 lines) | stat: -rw-r--r-- 12,679 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transistional//EN"><html><head><title>OpenLayer Offline Manual</title><style type="text/css" media="all">@import "../CrystalStyle.css";</style><body bgcolor="FFFFFF" ><div align="center" style="pagestyle"><table width="60%"><tr><td><div class="parentLinks"><a href="../index.html">OpenLayer</a> | <a href="../Bitmap.html">Bitmap</a> | <a href="../Bitmap/Load.html">Load</a></div><br><div class="BigHeader">Load</div><br><div class=""><div class="Surrounded"><table><tr valign="top"><td align="right"><div class="FuncDef"><strong><font color="#777733">bool</font> <a href="../Bitmap/Load.html"><font color="#0000CC">Load</font></a>(</strong></div></td><td><div class="FuncDef"><strong><font color="#777733">const</font> <font color="#777733">char</font> *filename );
<br></strong></div></td></tr></table>
<br>Loads the Bitmap from a bitmap file, which may contain an alpha channel. Returns true in success.
<br></div>
<br>
<br><div class="Surrounded"><table><tr valign="top"><td align="right"><div class="FuncDef"><strong><font color="#777733">bool</font> <a href="../Bitmap/Load.html"><font color="#0000CC">Load</font></a>(</strong></div></td><td><div class="FuncDef"><strong><font color="#777733">const</font> <font color="#777733">char</font> *rgbFilename, <font color="#777733">const</font> <font color="#777733">char</font> *alphaFilename );
<br></strong></div></td></tr></table>
<br>Loads the Bitmap from two separate bitmaps, one bitmap for the color information and one 8-bit bitmap for the transparency information. Returns true in success.
<br></div>
<br>
<br><div class="Surrounded"><table><tr valign="top"><td align="right"><div class="FuncDef"><strong><font color="#777733">bool</font> <a href="../Bitmap/Load.html"><font color="#0000CC">Load</font></a>(</strong></div></td><td><div class="FuncDef"><strong>BITMAP *allegroBmp, <font color="#777733">bool</font> hasAlphaChannel = <font color="#774422">false</font>,
<br><font color="#777733">bool</font> convertMagicPink = <font color="#774422">false</font> );
<br></strong></div></td></tr></table>
<br>Loads the bitmap from an Allegro bitmap. If convertMagicPink is true the magic pink pixels in the bitmap will be converted to transparent pixels in the Bitmap.
<br>
<br>OpenLayer doesn't free the passed BITMAP even if the Bitmap is destroyed.
<br></div>
<br><div class="Surrounded"><table><tr valign="top"><td align="right"><div class="FuncDef"><strong><font color="#777733">bool</font> <a href="../Bitmap/Load.html"><font color="#0000CC">Load</font></a>(</strong></div></td><td><div class="FuncDef"><strong>BITMAP *allegroBmp, <font color="#777733">int</font> conversionMode );
<br></strong></div></td></tr></table>
<br>Same as above but the parameters are given by using a bitwise "or" of the following conversion parameters: HAS_ALPHA_CHANNEL and CONVERT_MAGIC_PINK.
<br></div>
<br>
<br>The loaded bitmap may be in any format that is supported by Allegro (bmp, pcx, tga) or by any add-on libraries you've installed (Loadpng for pngs or JPGAlleg for JPEGs, for example).
<br>
<br>Installing Loadpng is recommended as png files may contain an alpha channel to allow for transparent or translucent pixels. Png files also compress better than tga files. The latest OpenLayer's packages contain the loadpng, libpng and libz -libraries which are required to load png images.
<br>
<br>It's best to check if the loading succeedes or not. The file may not be found or the format may not be supported. OpenLayer logs all loading failures in allegro.log, though, so you can also check the log file to find out if the loading has failed. But instead of letting your program crash it's better to display a message for the end user to let him know what went wrong. You'll get better feedback for your game that way ;)</div><br><div class="MediumHeader">Examples</div><br><div class="Code"><font color="#999922">//&nbsp;Remember&nbsp;to&nbsp;call&nbsp;Setup::SetupProgram&nbsp;and&nbsp;Setup::SetupScreen&nbsp;before&nbsp;loading&nbsp;any&nbsp;bitmaps!&nbsp;//</font>
<br>
<br><font color="#999922">//&nbsp;Load&nbsp;myBmp&nbsp;from&nbsp;gfx/Bitmap.png&nbsp;//</font>
<br><a href="../Bitmap.html"><font color="#0000CC">Bitmap</font></a>&nbsp;myBmp;
<br>myBmp.<a href="../Bitmap/Load.html"><font color="#0000CC">Load</font></a>(&nbsp;<font color="#CC0000">"gfx/Bitmap.png"</font>&nbsp;);
<br>
<br><font color="#999922">//&nbsp;It's&nbsp;best&nbsp;to&nbsp;check&nbsp;if&nbsp;the&nbsp;loading&nbsp;succeedes!&nbsp;(Bitmap&nbsp;really&nbsp;exists)&nbsp;//</font>
<br><a href="../Bitmap.html"><font color="#0000CC">Bitmap</font></a>&nbsp;myBmp;
<br><font color="#447711">if</font>(&nbsp;myBmp.<a href="../Bitmap/Load.html"><font color="#0000CC">Load</font></a>(&nbsp;<font color="#CC0000">"gfx/Bitmap.png"</font>&nbsp;)&nbsp;==&nbsp;<font color="#774422">false</font>&nbsp;)&nbsp;{
<br>&nbsp;&nbsp;&nbsp;<font color="#999922">//&nbsp;Display&nbsp;an&nbsp;error&nbsp;message&nbsp;//</font>
<br>&nbsp;&nbsp;&nbsp;allegro_message(&nbsp;<font color="#CC0000">"Bitmap&nbsp;couldn't&nbsp;be&nbsp;loaded!"</font>&nbsp;);
<br>&nbsp;&nbsp;&nbsp;<font color="#999922">//&nbsp;Exit&nbsp;the&nbsp;program&nbsp;//</font>
<br>&nbsp;&nbsp;&nbsp;exit(-<font color="#994400">1</font>);
<br>}
<br>
<br><font color="#999922">//&nbsp;If&nbsp;you&nbsp;have&nbsp;BitmapColor.bmp&nbsp;that&nbsp;has&nbsp;the&nbsp;color&nbsp;information&nbsp;//</font>
<br><font color="#999922">//&nbsp;and&nbsp;an&nbsp;8-bit&nbsp;BitmapAlpha.bmp&nbsp;that&nbsp;contains&nbsp;the&nbsp;translucency:&nbsp;//</font>
<br><a href="../Bitmap.html"><font color="#0000CC">Bitmap</font></a>&nbsp;myBmp;
<br>myBmp.<a href="../Bitmap/Load.html"><font color="#0000CC">Load</font></a>(&nbsp;<font color="#CC0000">"gfx/BitmapColor.bmp"</font>,&nbsp;<font color="#CC0000">"gfx/BitmapAlpha.bmp"</font>&nbsp;);</div><div class=""><br><br><div class="MediumHeader">Other functions of the class <a href="../Bitmap.html"><font color="#0000CC">Bitmap</font></a></div><div class="Surrounded"><table size="100%" cellpadding="0" cellspacing="0"><tr><td halign="center" class="funclist"><a href="../Bitmap/Load.html">Load</a></td><td width="65%" halign="center"><div class="smalltext">Loads the bitmap</div></td></tr><tr><td halign="center" class="funclist"><a href="../Bitmap/Blit.html">Blit</a></td><td width="65%" halign="center"><div class="smalltext">Draws the Bitmap to the screen</div></td></tr><tr><td halign="center" class="funclist"><a href="../Bitmap/BlitRotated.html">BlitRotated</a></td><td width="65%" halign="center"><div class="smalltext">Draws the Bitmap to the screen rotated along a point</div></td></tr><tr><td halign="center" class="funclist"><a href="../Bitmap/BlitStretched.html">BlitStretched</a></td><td width="65%" halign="center"><div class="smalltext">Draws the Bitmap to the screen stretched to the specified size</div></td></tr><tr><td halign="center" class="funclist"><a href="../Bitmap/BlitTransformed.html">BlitTransformed</a></td><td width="65%" halign="center"><div class="smalltext">Draws the Bitmap to the screen rotated and stretched</div></td></tr><tr><td halign="center" class="funclist"><a href="../Bitmap/BlitDistorted.html">BlitDistorted</a></td><td width="65%" halign="center"><div class="smalltext">Draws the Bitmap to the screen with the given corner points</div></td></tr><tr><td halign="center" class="funclist"><a href="../Bitmap/Width.html">Width</a></td><td width="65%" halign="center"><div class="smalltext">Returns the width of the Bitmap</div></td></tr><tr><td halign="center" class="funclist"><a href="../Bitmap/Height.html">Height</a></td><td width="65%" halign="center"><div class="smalltext">Returns the height of the Bitmap</div></td></tr><tr><td halign="center" class="funclist"><a href="../Bitmap/LoadListOfBitmaps.html">LoadListOfBitmaps</a></td><td width="65%" halign="center"><div class="smalltext">Loads a list of bitmaps from the disk</div></td></tr><tr><td halign="center" class="funclist"><a href="../Bitmap/GetPixel.html">GetPixel</a></td><td width="65%" halign="center"><div class="smalltext">Returns the color value of a pixel</div></td></tr><tr><td halign="center" class="funclist"><a href="../Bitmap/Destroy.html">Destroy</a></td><td width="65%" halign="center"><div class="smalltext">Destroys the Bitmap</div></td></tr><tr><td halign="center" class="funclist"><a href="../Bitmap/IsValid.html">IsValid</a></td><td width="65%" halign="center"><div class="smalltext">Checks if the Bitmap was loaded correctly</div></td></tr><tr><td halign="center" class="funclist"><a href="../Bitmap/Save.html">Save</a></td><td width="65%" halign="center"><div class="smalltext">Saves the Bitmap to disk with the specified filename</div></td></tr><tr><td halign="center" class="funclist"><a href="../Bitmap/CopyFromScreen.html">CopyFromScreen</a></td><td width="65%" halign="center"><div class="smalltext">Copies a region of the game window to the Bitmap</div></td></tr><tr><td halign="center" class="funclist"><a href="../Bitmap/GetMemoryBitmap.html">GetMemoryBitmap</a></td><td width="65%" halign="center"><div class="smalltext">Returns a memory bitmap copy of (part of) the Bitmap</div></td></tr><tr><td halign="center" class="funclist"><a href="../Bitmap/GetCollisionPoly.html">GetCollisionPoly</a></td><td width="65%" halign="center"><div class="smalltext">Returns the generated collision polygon for the Bitmap</div></td></tr><tr><td halign="center" class="funclist"><a href="../Bitmap/SetDefaultPivot.html">SetDefaultPivot</a></td><td width="65%" halign="center"><div class="smalltext">Sets the default pivot point</div></td></tr><tr><td halign="center" class="funclist"><a href="../Bitmap/GetDefaultPivot.html">GetDefaultPivot</a></td><td width="65%" halign="center"><div class="smalltext">Returns the default pivot point</div></td></tr><tr><td colspan="2"><br><div class="SmallHeader"><font color="#775500">Advanced functions</font></div><br></td></tr><tr><td halign="center" class="funclist"><a href="../Bitmap/GetPixelPacked.html">GetPixelPacked</a></td><td width="65%" halign="center"><div class="smalltext">
Returns the color value of the specified pixel in a packed integer</div></td></tr><tr><td halign="center" class="funclist"><a href="../Bitmap/SendToGPU.html">SendToGPU</a></td><td width="65%" halign="center"><div class="smalltext">Sends the Bitmap to the graphics card</div></td></tr><tr><td halign="center" class="funclist"><a href="../Bitmap/UnloadFromGPU.html">UnloadFromGPU</a></td><td width="65%" halign="center"><div class="smalltext">Unloads the Bitmap from the graphics card</div></td></tr><tr><td halign="center" class="funclist"><a href="../Bitmap/Select.html">Select</a></td><td width="65%" halign="center"><div class="smalltext">
Selects the Bitmap as the active texture of OpenGL</div></td></tr><tr><td halign="center" class="funclist"><a href="../Bitmap/UseAutoDelete.html">UseAutoDelete</a></td><td width="65%" halign="center"><div class="smalltext">
Chooses the Bitmap to be automatically deleted when the program quits</div></td></tr><tr><td halign="center" class="funclist"><a href="../Bitmap/HasAlphaChannel.html">HasAlphaChannel</a></td><td width="65%" halign="center"><div class="smalltext">Checks if the Bitmap has an alpha channel</div></td></tr><tr><td halign="center" class="funclist"><a href="../Bitmap/StartFastBlitting.html">StartFastBlitting</a></td><td width="65%" halign="center"><div class="smalltext">This function should be called right before using FastBlit</div></td></tr><tr><td halign="center" class="funclist"><a href="../Bitmap/FastBlit.html">FastBlit</a></td><td width="65%" halign="center"><div class="smalltext">A faster version of Blit</div></td></tr><tr><td halign="center" class="funclist"><a href="../Bitmap/FinishFastBlitting.html">FinishFastBlitting</a></td><td width="65%" halign="center"><div class="smalltext">This function should be called after calling FastBlit</div></td></tr><tr><td halign="center" class="funclist"><a href="../Bitmap/UnloadToMemory.html">UnloadToMemory</a></td><td width="65%" halign="center"><div class="smalltext">Unloads the Bitmap from the graphics card keeping the image data saved in the Bitmap</div></td></tr><tr><td halign="center" class="funclist"><a href="../Bitmap/TexturedQuad.html">TexturedQuad</a></td><td width="65%" halign="center"><div class="smalltext">Outputs a raw textured quad to the video card</div></td></tr></table></div><br><div class=""><a href="../index.html">Back to the main page of the manual</a></div><br>Questions about Load? Click <a href="http://crystalstorm.ath.cx/index.php?lan=en&page=CreateFeedback&subject=Load">here.</a></div></td></tr></table></body></html>