Documentation Project 1
ContentsIndexHome
PreviousUpNext
sack::image::MakeSubImageEx Function
C++
__cdecl IMAGE_PROC Image MakeSubImageEx(Image pImage, S_32 x, S_32 y, _32 width, _32 height DBG_PASS);
#define MakeSubImage( image, x, y, w, h ) MakeSubImageEx( image, x, y, w, h DBG_SRC )
Parameters 
Description 
Image pImage 
image to make the sub image in 
S_32 x 
signed location of the top side of the sub-image 
S_32 y 
signed location of the left side of the sub-image 
_32 width 
how wide to make the sub-image 
height 
how tall to make the sub-image 

NULL if the input image is NULL. 

Otherwise returns an Image.

Creates a sub image region on an image. Sub-images may be used like any other image. There are two uses for this sort of thing. OH, the sub image shares the exact data of the parent image, and is not a copy.

Use 1: An image might contain a grid of symbols or characters, each exactly the same size. These may be token peices used in a game or a special graphic font.

Image peices_image = LoadImageFile( "Game Peices.image" );
PLIST peices = NULL;
int x, y;
#define PEICE_WIDTH 32
#define PEICE_HEIGHT 32
for( x = 0; x < 10; x++ )
   for( y = 0; y < 2; y++ )
   {
       AddLink( &peices, MakeSubImage( peices_image
                                     , x * PEICE_WIDTH, y * PEICE_HEIGHT
                                     , PEICE_WIDTH, PEICE_HEIGHT );
   }
      
// at this point there we have a list with all the tokens,
// which were 32x32 pixels each.
// Any of these peice images may be output using a scaled or direct blot.

 

Use 2: Partitioning views on an image for things like controls and other clipped regions.

Image image = MakeImageFile( 1024, 768 );
Image clock = MakeSubImage( image, 32, 32, 150, 16 );
      
DrawString( clock, 0, 0, BASE_COLOR_WHITE, BASE_COLOR_BLACK, "Current Time..." );
Copyright (c) 2010. All rights reserved.
What do you think about this topic? Send feedback!