Difference between revisions of "GSDP:GAM100/CProcessing/imageData()"

From Inside
Jump to: navigation, search
>Zachary.logsdon
(New page: {{GSDP:GAM100API.css}} = imageData() = == Description == Returns the pixel data array of a PImage if it was created with the CP_IMAGE_STORE_PIXEL_DATA s...)
 
>Zachary.logsdon
 
(2 intermediate revisions by the same user not shown)
Line 2: Line 2:
 
= imageData() =
 
= imageData() =
 
== Description ==
 
== Description ==
Returns the pixel data array of a [[GSDP:GAM100/CProcessing/PImage |PImage]] if it was created with the CP_IMAGE_STORE_PIXEL_DATA set by * [[GSDP:GAM100/CProcessing/setImageFlags() |setImageFlags()]]
+
Returns the pixel data array of a [[GSDP:GAM100/CProcessing/PImage |PImage]] if it was created using one of the advanced image functions and set the copyPixelData bool to be true.
  
 
==== Parameters ====
 
==== Parameters ====
Line 12: Line 12:
 
<syntaxhighlight lang='c'>
 
<syntaxhighlight lang='c'>
 
PImage justin_face;
 
PImage justin_face;
PImage tinted_justin_face;
 
 
int x_size, y_size;
 
int x_size, y_size;
  
 
void init()
 
void init()
 
{
 
{
  setImageFlags(CP_IMAGE_STORE_PIXEL_DATA);
+
   justin_face = loadImageAdvanced("./Assets/justin1.png", true, false);
   justin_face = loadImage("./Assets/justin1.png");
+
 
  tinted_justin_face = imageCreateTint(justin_face, color(255, 0, 0, 255));
 
 
   x_size = imageWidth(justin_face);
 
   x_size = imageWidth(justin_face);
 
   y_size = imageHeight(justin_face);
 
   y_size = imageHeight(justin_face);
 +
 +
  unsigned char* pixel_data = imageData(justin_face);
 +
 +
  // Go through and invert the color of the image
 +
  unsigned i;
 +
  for (i = 0; i < x_size*y_size*4; ++i)
 +
  {
 +
    if (i % 4 == 3)
 +
      continue;
 +
 +
    pixel_data[i] = (unsigned char)255 - pixel_data[i];
 +
  }
 +
 +
  imageUpdate(justin_face);
 
}
 
}
  
float rotation = 0;
 
 
void update()
 
void update()
 
{
 
{
 
   background(color(255, 255, 255, 255));
 
   background(color(255, 255, 255, 255));
   imageRotated(tinted_justin_face, mouseX, mouseY, 100, 150, 255, rotation);
+
   image(justin_face, canvasWidth/2, canvasHeight/2, x_size, y_size, 255);
  rotation++;
 
 
}
 
}
 
</syntaxhighlight>
 
</syntaxhighlight>
Line 35: Line 45:
 
==== Related ====                             
 
==== Related ====                             
 
* [[GSDP:GAM100/CProcessing                          |Main Page                ]]
 
* [[GSDP:GAM100/CProcessing                          |Main Page                ]]
* [[GSDP:GAM100/CProcessing/loadImage() |loadImage() ]]
+
* [[GSDP:GAM100/CProcessing/loadImage()           |loadImage()           ]]
* [[GSDP:GAM100/CProcessing/image()     |image()     ]]
+
* [[GSDP:GAM100/CProcessing/loadImageAdvanced()  |loadImageAdvanced()  ]]
* [[GSDP:GAM100/CProcessing/imageRotated()     |imageRotated()     ]]
+
* [[GSDP:GAM100/CProcessing/image()               |image()               ]]
* [[GSDP:GAM100/CProcessing/imageSize() |imageSize() ]]
+
* [[GSDP:GAM100/CProcessing/imageRotated()       |imageRotated()       ]]
* [[GSDP:GAM100/CProcessing/imageMode() |imageMode() ]]
+
* [[GSDP:GAM100/CProcessing/imageSize()           |imageSize()           ]]
* [[GSDP:GAM100/CProcessing/setImageFlags() |setImageFlags() ]]
+
* [[GSDP:GAM100/CProcessing/imageMode()           |imageMode()           ]]
* [[GSDP:GAM100/CProcessing/createImage() |createImage() ]]
+
* [[GSDP:GAM100/CProcessing/createImage()         |createImage()         ]]
* [[GSDP:GAM100/CProcessing/freeImage() |freeImage() ]]
+
* [[GSDP:GAM100/CProcessing/createImageAdvanced() |createImageAdvanced() ]]
* [[GSDP:GAM100/CProcessing/imageWidth() |imageWidth() ]]
+
* [[GSDP:GAM100/CProcessing/freeImage()           |freeImage()           ]]
* [[GSDP:GAM100/CProcessing/imageHeight() |imageHeight() ]]
+
* [[GSDP:GAM100/CProcessing/imageWidth()         |imageWidth()         ]]
* [[GSDP:GAM100/CProcessing/imagePixel() |imagePixel() ]]
+
* [[GSDP:GAM100/CProcessing/imageHeight()         |imageHeight()         ]]
 +
* [[GSDP:GAM100/CProcessing/imagePixel()         |imagePixel()         ]]
 
* [[GSDP:GAM100/CProcessing/imageCreateSubimage() |imageCreateSubimage() ]]
 
* [[GSDP:GAM100/CProcessing/imageCreateSubimage() |imageCreateSubimage() ]]
* [[GSDP:GAM100/CProcessing/imageCreateTint() |imageCreateTint() ]]
+
* [[GSDP:GAM100/CProcessing/imageCreateSubimageAdvanced() |imageCreateSubimageAdvanced() ]]
* [[GSDP:GAM100/CProcessing/imageData() |imageData() ]]
+
* [[GSDP:GAM100/CProcessing/imageCreateTint()     |imageCreateTint()     ]]
* [[GSDP:GAM100/CProcessing/imageUpdate() |imageUpdate() ]]
+
* [[GSDP:GAM100/CProcessing/imageCreateTintAdvanced()    |imageCreateTintAdvanced()    ]]
* [[GSDP:GAM100/CProcessing/readFrameBuffer() |readFrameBuffer() ]]
+
* [[GSDP:GAM100/CProcessing/imageData()           |imageData()           ]]
 +
* [[GSDP:GAM100/CProcessing/imageUpdate()         |imageUpdate()         ]]
 +
* [[GSDP:GAM100/CProcessing/readFrameBuffer()     |readFrameBuffer()     ]]
 +
* [[GSDP:GAM100/CProcessing/readFrameBufferAdvanced()    |readFrameBufferAdvanced()    ]]

Latest revision as of 17:39, 5 October 2019

imageData()

Description

Returns the pixel data array of a PImage if it was created using one of the advanced image functions and set the copyPixelData bool to be true.

Parameters

imageCreateTint(PImage img)

  • img - (PImage) The image to extract the pixel data from.

Example

PImage justin_face;
int x_size, y_size;

void init()
{
  justin_face = loadImageAdvanced("./Assets/justin1.png", true, false);

  x_size = imageWidth(justin_face);
  y_size = imageHeight(justin_face);

  unsigned char* pixel_data = imageData(justin_face);

  // Go through and invert the color of the image
  unsigned i;
  for (i = 0; i < x_size*y_size*4; ++i)
  {
    if (i % 4 == 3)
      continue;

    pixel_data[i] = (unsigned char)255 - pixel_data[i];
  }

  imageUpdate(justin_face);
}

void update()
{
  background(color(255, 255, 255, 255));
  image(justin_face, canvasWidth/2, canvasHeight/2, x_size, y_size, 255);
}

Related

Personal tools
Namespaces

Variants
Actions
Navigation
NameSpaces:>
Tools
Dynamic:>