Skip to content
This repository has been archived by the owner on Jan 25, 2023. It is now read-only.

Commit

Permalink
Show lines on Histogram for value under mouse pointer
Browse files Browse the repository at this point in the history
  • Loading branch information
ktgw0316 committed Jan 23, 2022
1 parent beddbf5 commit f4d8dfe
Showing 1 changed file with 11 additions and 1 deletion.
Expand Up @@ -22,6 +22,7 @@ public class HistogramPreview extends Preview implements PaintListener {
private int[][] bins = null;
private double[][] controlPoints = null;
private int currentFocusZone = -1;
private Color sample;
final ImageEditorEngine engine;

HistogramPreview(final ImageEditorEngine engine) {
Expand All @@ -38,7 +39,7 @@ public void setDropper(Point p) {
if (p == null || engine == null)
return;

Color sample = engine.getPixelValue(p.x, p.y);
sample = engine.getPixelValue(p.x, p.y);
final int zone;
if (sample == null) {
zone = -1;
Expand Down Expand Up @@ -126,6 +127,8 @@ private int yscale(double y) {
}
}

final int maxY = (int) (4.5 + miny); // == yscale(max)

scaler s = new scaler();

for (int c = 0; c < bins.length; c++) {
Expand Down Expand Up @@ -174,6 +177,13 @@ private int yscale(double y) {
g2d.fill(gp);
g2d.setComposite(AlphaComposite.SrcOver);
g2d.draw(gp);

if (sample != null) {
val value = 255 * sample.getRGBColorComponents(null)[c];
val position = calcZone(value) / 16;
val sampleX = (int) (position * width + minx);
g2d.drawLine(sampleX, zeroY, sampleX, maxY);
}
}
}

Expand Down

0 comments on commit f4d8dfe

Please sign in to comment.