GSDP:GAM100/CProcessing/CP Image CreateFromData()

From Inside
Jump to: navigation, search

CP_Image_CreateFromData()

Description

Creates a CP_Image from the given data

Function Definition

CP_Image CP_Image_CreateFromData(int width, int height, unsigned char* pixelData);

Parameters

  • width- (int) The width you want the created image to be (must correspond to the size of the data given)
  • height- (int) The height you want the created image to be (must correspond to the size of the data given)
  • pixelData- (unsigned char*) The data to use to create the new image

Return

Example

CP_Image justinFace = NULL;

void init()
{
  unsigned char pixelData[] = {
    255, 0, 0, 255, 255, 0, 0, 255, // 2 red pixels
    0, 0, 255, 255, 0, 0, 255, 255  // 2 blue pixels
  };


  justinFace = CP_Image_CreateFromData(2, 2, pixelData);
}

void update()
{
  CP_Settings_Background(CP_Color_Create(255, 255, 255, 255));

  int width = CP_System_GetWindowWidth();
  int height = CP_System_GetWindowHeight();

    // draws the top left quarter of the image
  CP_Image_DrawImage(justinFace, width / 2, height / 2, width, height, 255);
}

void shutdown()
{
  CP_Image_Free(justinFace);
}

Related

Personal tools
Namespaces

Variants
Actions
Navigation
NameSpaces:>
Tools
Dynamic:>