• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Reading and writing pixels at X,Y

Engaged ,
Sep 03, 2018 Sep 03, 2018

Copy link to clipboard

Copied

Hi all;

Very new to the SDK but making great progress.

I see that using the following function, we can write pixels at a coordinate (as opposed to iterating through every pixel):

PF_Pixel *sampleIntegral32(PF_EffectWorld &def, int x, int y){

return (PF_Pixel*)((char*)def.data +

(y * def.rowbytes) +

(x * sizeof(PF_Pixel)));

}

And then we call it using:

PF_Pixel *myPixel = sampleIntegral32(*output,x,y);

myPixel->red      = 255;

myPixel->green  = 255;

myPixel->blue     = 255;

myPixel->alpha   = 255;

But how does one read a pixel at X,Y?

Thanks,

-Richard

TOPICS
SDK

Views

466

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Deleted User
Sep 03, 2018 Sep 03, 2018

The answer is already in the code

The myPixel pointer already contains all the pixel data you need (myPixel->red is the red channel, myPixel->green is the green channel, etc).

Here is an example to read the blue channel value, decrease it by 10, then write it back to the red channel (no boundary checks!)

myPixel->red      = myPixel->blue - 10;

Be aware that the code above is only valid in 8bpc (values 0..255), you should also support 16bpc and 32bpc

Votes

Translate

Translate
Guest
Sep 03, 2018 Sep 03, 2018

Copy link to clipboard

Copied

The answer is already in the code

The myPixel pointer already contains all the pixel data you need (myPixel->red is the red channel, myPixel->green is the green channel, etc).

Here is an example to read the blue channel value, decrease it by 10, then write it back to the red channel (no boundary checks!)

myPixel->red      = myPixel->blue - 10;

Be aware that the code above is only valid in 8bpc (values 0..255), you should also support 16bpc and 32bpc

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Sep 04, 2018 Sep 04, 2018

Copy link to clipboard

Copied

LATEST

Well don't I feel foolish.

Thank you for the explanation.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines