Peter, I don't know a method for working with a bitmap image. (there is NO histogram in bitmap mode) Would you be able to switch modes to grayscale and back? If so then this may work although Im NOT sure if I've overlooked something here. I only tested with a small file. I would not expect this kind of thing to be fast. $.sleep(500); & WaitForRedraw(); can come out there just so I can see whats happening in the GUI. #target photoshop app.bringToFront(); function main() { if (app.documents.length == 0) { alert('You have NO document open?'); return; } var whiteRef = new SolidColor(); whiteRef.rgb.red = 255; whiteRef.rgb.green = 255; whiteRef.rgb.blue = 255; var docRef = app.activeDocument; with (docRef) { // Horizontal selection selection.select([[0, 0], [width , 0], [width, 1], [0, 1]]); if (channels[0].histogram[0] == 1) { alert('Single Pixel'); selection.fill(whiteRef); } for (var i = 0; i < height-1; i++) { selection.translateBoundary(0, 1); $.sleep(500); WaitForRedraw(); if (channels[0].histogram[0] == 1) { alert('Single Pixel'); selection.fill(whiteRef); } } // Vertical selection selection.select([[0, 0], [1 , 0], [1, height], [0, height]]); if (channels[0].histogram[0] == 1) { alert('Single Pixel'); selection.fill(whiteRef); } for (var i = 0; i < width-1; i++) { selection.translateBoundary(1, 0); $.sleep(500); WaitForRedraw(); if (channels[0].histogram[0] == 1) { alert('Single Pixel'); selection.fill(whiteRef); } } selection.deselect(); } }; main(); // Redraw the Screen function WaitForRedraw() { var eventWait = charIDToTypeID('Wait'); var enumRedrawComplete = charIDToTypeID('RdCm'); var typeState = charIDToTypeID('Stte'); var keyState = charIDToTypeID('Stte'); var desc = new ActionDescriptor(); desc.putEnumerated(keyState, typeState, enumRedrawComplete); executeAction(eventWait, desc, DialogModes.NO); }
... View more