|
CreateImage | |
CreateImage ImageIndex, Width, Height, [Format =1] | |
Parameters: ImageIndex = The Index of the image that you wish to create. Width = The Width of the image in pixels Height = The Height of the image in pixels [Format =1] = Format of image to create, Format defaults to Video (1), use 2 for FX and 8 for AFX |
|
Returns: NONE | |
CreateImage creates a blank image in memory ready for use. This Image can then be drawn or even have graphics drawn to it. Conceptually an image nothing more than a two dimensional grid of dots(pixels), each dot is made up of an RGB colour (or an ARGB colour). Images are formatted X by Y dots, where the zero / zero point is found in the upper left hand corner, the same as the screen. Example, You can think of an Image as a picture, You might use them to store the individual frames of your game characters, game logos, backdrops, map tiles etc etc (Note: generally you'd use LoadImage to load animation images, or LoadMapGFX for map graphics files). You can perform a host of drawing operations directly to an Image, ranging from primitive drawing commands such as Dots, Box, Lines, Circles, Polygons (Tri,TextureTri etc) through to drawing other images, sprites, maps onto an image also. One common usage, could be to draw a collection primitive graphical elements to an image, then rather than drawing those elements each time in our game, we show the player the pre-drawn image in it's place. This technique is often used in User Interfaces in games to help speed up rendering. In fact lots of visual effects can be created this way also, so it's well worth exploring. Images can also be manipulated using the built in image processing commands, such as ScaleImage, MirrorImage, BlurImage etc . These commands are not generally designed for real time usage as they're destructive to the image. Meaning they, take the original image and manipulate it's dots/pixels the in ways that permanently alter it. For example if you scale an image via ScaleImage, then this command resizes that actual image data to what ever size you select. So generally the image processing commands are for preparation of images, rather than dynamic usage. You can manipulate images dynamically using commands like DrawRotatedImage, DrawAlphaImage, and primarily via using SPRITES, which have a number of drawing and collision methods to help bring your games to life. In PlayBASIC we have three main image formats. Each image format has certain characteristics, that the other generally don't share. So choosing the correct format for what you plan to do, is very important part of writing efficient PlayBASIC programs. Our three image formats are Video (1), FX(2) and AFX (8), of which FX and AFX are directly basically related. AFX is simply an FX image with Alpha Channel, where are FX images don't consider alpha channel, neither do Video for that matter. Video images are stored in the computer graphics card, these are generally the fastest to render, but they can't be manipulated (rotated, alpha blended, scaled) real time, so they're for fixed images. FX/AFX are stored in the computers main memory, allowing them to be rotated, blended, scaled, tinted etc.. but they're generally slower to render than video images. So choosing the image type can have a dramatic impact on the performance. We highly recommended reading the IMAGES tutorials also! Image Formats Parameters : PlayBASIC has various types of image formats, each one is suited for different uses. 1 = Video - Image is created in Video Memory 2 = FX - System Memory Image 8 = AFX - System Memory Image With Alpha Channel FACTS: * CreateImage does not change PlayBASIC current graphics surface when graphics output (See GetSurface). So if you want to redirect all drawing operations to a newly created image, you'll have to do this manually via RenderToImage. * By default new images use BLACK as the transparent colour. Black is equal to RGB(0,0,0) Mini Tutorial: This example creates Image #1 in memory. Next it renders some graphics to it, then it draws this image to the screen.
|
Related Info: | CreateFxImage | CreateFxImageEx | DeleteImage | DrawImage | GetFreeImage | LoadImage | NewFxImage | NewImage | PrepareFXimage | RenderToImage : |
|
|||||||||||||||||||||||||||||||||||||||
(c) Copyright 2002 - 2024 - Kevin Picone - PlayBASIC.com |