Table of Contents | ||||||||||||||||||||
|
||||||||||||||||||||
CreateImage | ||||||||||||||||||||
Purpose creates a new, blank image surface object to blit to (or from) |
||||||||||||||||||||
Protoype void CImageMngr::CreateImage (Uint32 ui_flags, string str_img_id, int i_width, int i_height, int i_depth, int i_xpos, int i_ypos, RGB_SET rgb_key = RGB_SET(), bool b_bound = false, bool b_visible = true) |
||||||||||||||||||||
Parameters
|
||||||||||||||||||||
Description This function is used to create a new surface object that can then be used by the game as a regular image object. The reason for using this function rather than AddImage() is that this function does not load an image from a file, it just creates a new, blank surface of certain specifications. It has many similarities to AddImage() however - you must pass in the new object's unique ID as well as having the option of setting its initial screen location. The width and height of the new surface dictate what can be displayed on it. Anything larger than the surface that is blitted on to it will not be totally displayed. In this was you can create a psuedo clip window by blitting a larger image onto a smaller surface. Surface Flags Since you are creating a new surface from scratch, you must define the properties of that surface. AddImage() does that for you when it loads in the image file, but here you are dealing with raw functionality. In most cases you can use the predefined flag combination of NEW_SURFACE to create the surface from. This enables hardware acceleration for the surface as well as color key transparency. If you need more, you can logically OR the following flags together to create surface properties. It's suggested that you OR them with NEW_SURFACE.
Transparency Image transparency is done with color keys. Since each image is assigned a color key, each image can have its own transparency color. The way color keys work is the key is stored as an RGB value. When an image with a color key is blitted to another surface, all pixels in the image that match the RGB key are not blitted, hence the transparency. Color keys are assigned as RGB_SET objects. Passing in a null RGB_SET will disable color-keying for that image. Image Binding This is simply whether or not this image object is going to be used (and thus rendered) by another manager class. For instance, an icon image is bound to a button object of CButtonMngr. CButtonMngr is the class that actually renders the image on the screen, not CImageMngr. However if an image is not bound to any other manager then CImageMngr will render it. |
||||||||||||||||||||
Use CImageMngr image; image.CreateImage(NEW_SURFACE, "my_image", 250, 250, 16, 0, 0, RGB_SET(255, 0, 255), false); |
||||||||||||||||||||
|
||||||||||||||||||||
|