Skip to main content
Participant
February 2, 2023
Answered

iterate and look at pixels

  • February 2, 2023
  • 1 reply
  • 260 views

Hi,

i'm trying to do something that should be really really simple - write a plugin that iterates over all the pixels of the current frame and outputs the values (pixel coordinates, rbg + alpha) to the file. However, some of the lines in the file that I'm getting are quite strange-looking - there's some duplicates, some lines don't make sense at all (they have too many or few values) etc etc.

 

here's the relevant snippet

static PF_Err 
Render (
	PF_InData		*in_data,
	PF_OutData		*out_data,
	PF_ParamDef		*params[],
	PF_LayerDef		*outputP)
{
    PF_Err 				err = PF_Err_NONE;
    AEGP_SuiteHandler	suites(in_data->pica_basicP);
    PF_EffectWorld		*inputP 		= &params[0]->u.ld;
    PF_Pixel8			*bop_outP		= 	outputP->data,
				*bop_inP		= 	inputP->data;

    std::string curtime = std::to_string(in_data->current_time);
    std::ofstream outfile("C:/somepath/" + curtime + ".txt");
    outfile << "size " << inputP->height << " " << inputP->width << "\n";
    outfile << "x   y   R   G   B   A \n";


    for (A_long yL = 0; yL < inputP->height; yL++) {
        for (A_long xL = 0; xL < inputP->width; xL++) {
            outfile << (int) yL << "  " << (int) xl << "  "
                    << (int) bop_inP->red << "   "
                    << (int) bop_inP->green << "   "
                    << (int) bop_inP->blue << "   "
                    << (int) bop_inP->alpha << "\n";
            *bop_outP++ = *bop_inP++;
        }
    }

    return err;
}

 

 

Any ideas why that might be happening ?

 

This topic has been closed for replies.
Correct answer Bruce Bullis

I don't see any usage of rowbytes, in [above]; there could be variance at the end of each row.

I'd recommend avoiding such vagaries, by using the iteration callback functions as defined in AE_EffectCB.h, in the After Effects SDK; the Gamma_Table, SDK_Noise, and Custom_ECW_UI samples use them.


1 reply

Bruce Bullis
Bruce BullisCorrect answer
Legend
February 2, 2023

I don't see any usage of rowbytes, in [above]; there could be variance at the end of each row.

I'd recommend avoiding such vagaries, by using the iteration callback functions as defined in AE_EffectCB.h, in the After Effects SDK; the Gamma_Table, SDK_Noise, and Custom_ECW_UI samples use them.