Does PS Scripiting have a function to retrieve colour information for a specific pixel at reference (x,y)? if so, where would I find a list of these types of functions?
Regards,
Bob
Getting Colour Information for a pixel
Getting Colour Information for a pixel
xbytor posted this recently on the Adobe forum. I think this code was originally written by fazstp.
Code: Select allfunction GetPixel( varX, varY ) {
// make new 1 pixel selection
activeDocument.selection.select( [[varX, varY], [varX + 1, varY], [varX + 1,
varY + 1], [varX, varY + 1]] );
// init colour
var pColour = new SolidColor();
// get red histogram
var pChannel = activeDocument.channels["Red"].histogram;
// check 0 to 255
for ( i = 0; i <= 255; i++ ) {
if ( pChannel ) {
pColour.rgb.red = i;
break;
}
}
// get green histogram
pChannel = activeDocument.channels["Green"].histogram;
// check 0 to 255
for ( i = 0; i <= 255; i++ ) {
if ( pChannel ) {
pColour.rgb.green = i;
break;
}
}
// get blue histogram
pChannel = activeDocument.channels["Blue"].histogram;
// check 0 to 255
for ( i = 0; i <= 255; i++ ) {
if ( pChannel ) {
pColour.rgb.blue = i;
break;
}
}
return pColour;
}
Code: Select allfunction GetPixel( varX, varY ) {
// make new 1 pixel selection
activeDocument.selection.select( [[varX, varY], [varX + 1, varY], [varX + 1,
varY + 1], [varX, varY + 1]] );
// init colour
var pColour = new SolidColor();
// get red histogram
var pChannel = activeDocument.channels["Red"].histogram;
// check 0 to 255
for ( i = 0; i <= 255; i++ ) {
if ( pChannel ) {
pColour.rgb.red = i;
break;
}
}
// get green histogram
pChannel = activeDocument.channels["Green"].histogram;
// check 0 to 255
for ( i = 0; i <= 255; i++ ) {
if ( pChannel ) {
pColour.rgb.green = i;
break;
}
}
// get blue histogram
pChannel = activeDocument.channels["Blue"].histogram;
// check 0 to 255
for ( i = 0; i <= 255; i++ ) {
if ( pChannel ) {
pColour.rgb.blue = i;
break;
}
}
return pColour;
}
Getting Colour Information for a pixel
Thanks Mick. I'll see how it runs tomorrow.
Regards,
Bob
Regards,
Bob
Getting Colour Information for a pixel
Don't thank me Bob. I just posted it because I had seen it a few days earlier.