GSDP:GAM100/CProcessing/CP Image DrawSubImage()

From Inside
Jump to: navigation, search

CP_Image_DrawSubImage()

Description

Draws a given CP_Image to the screen using the given position, size, texture coordinates, and alpha

Function Definition

void CP_Image_DrawSubImage(CP_Image image, float x, float y, float w, float h, float s0, float t0, float s1, float t1, int alpha);

Parameters

  • image- (CP_Image) The image that you want to draw to the screen
  • x- (float) The x coordinate of the image in screen coordinates
  • y- (float) The y coordinate of the image in screen coordinates
  • w- (float) The width to draw the image in pixels
  • h- (float) The height to draw the image in pixels
  • s0- (float) The left most pixel of the sub-image(far left = 0)
  • t0- (float) The top most pixel of the sub-image (top = 0)
  • s1- (float) The right most pixel for the sub-image (far right = image width)
  • t0- (float) The bottom most pixel for the sub-image (bottom = image height)
  • alpha- (int) The alpha value to draw the image with (0-255)

Return

  • void- This function does not return anything

Example

CP_Image justinFace = NULL;

void init()
{
  justinFace = CP_Image_Load("./Assets/Justins_face.png");
}

void update()
{
  CP_Settings_Background(CP_Color_Create(255, 255, 255, 255));
 
  int width = CP_System_GetWindowWidth();
  int height = CP_System_GetWindowHeight();

  int imageWidth = CP_Image_GetWidth(justinFace);
  int imageHeight = CP_Image_GetHeight(justinFace);

    // draws the top left quarter of the image
  CP_Image_DrawSubImage(justinFace, (width / 2), (height / 2), width, height, 0, 0, imageWidth / 2, imageHeight / 2, 255);
}

void shutdown()
{
  CP_Image_Free(justinFace);
}

Related

Personal tools
Namespaces

Variants
Actions
Navigation
NameSpaces:>
Tools
Dynamic:>