GSDP:GAM100/CProcessing/CP Image GetWidth()
From Inside
< GSDP:GAM100 | CProcessing
CP_Image_GetWidth()
Description
Get the width in pixels of a given CP_Image
Function Definition
int CP_Image_GetWidth(CP_Image image);
Parameters
- image- (CP_Image) The image that you want to know the width of
Return
- int- The width of the image in pixels
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_Image_GetWidth(justinFace);
int windowWidth = CP_System_GetWindowWidth();
int windowHeight = CP_System_GetWindowHeight();
CP_Image_Draw(justinFace, windowWidth / 2, windowHeight / 2, windowWidth / 2, windowHeight / 2, 255);
}
void shutdown()
{
CP_Image_Free(justinFace);
}