Copy link to clipboard
Copied
Hello. In the Gamma Table example there is this code:
typedef struct {
PF_Fixed gamma_val;
A_u_char lut[256];
} Gamma_Table;
typedef struct {
unsigned char *lut;
} GammaInfo;
How come a struct is used to create a pointer to lut inside Gamma_Table? If there is only one data type is this pointless or does it have a reason? Thanks.
The first struct (Gamma_Table) is used as the effect's sequence data. It contains the gamma lookup table (lut), and the gamma value. In Render, the value of gamma_val is compared against the parameter, and if they differ, the lut is re-generated.
The second struct (GammaInfo) is used as the refcon, which is passed to the iterate function to process the pixels. In this case the lut is just a pointer, which is assigned the address of the sequence data lut.
The reason for having separate structs is t
...Copy link to clipboard
Copied
The first struct (Gamma_Table) is used as the effect's sequence data. It contains the gamma lookup table (lut), and the gamma value. In Render, the value of gamma_val is compared against the parameter, and if they differ, the lut is re-generated.
The second struct (GammaInfo) is used as the refcon, which is passed to the iterate function to process the pixels. In this case the lut is just a pointer, which is assigned the address of the sequence data lut.
The reason for having separate structs is to keep the sequence and render data separate. In this case the only data passed to the iterate function is the lut, but in reality you may have other data that's required for rendering. You'd store that in the second struct.
Hope that makes sense!
Copy link to clipboard
Copied
Thanks Christian. I was initially confused because structs are for storing variables of different types, and in this example the second struct only contains one item. But your explanation makes sense.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more