diff --git a/plugins/org.eclipaint.editor/src/org/eclipaint/editor/ImageEditor.java b/plugins/org.eclipaint.editor/src/org/eclipaint/editor/ImageEditor.java index 7a0e5b0..b6e3005 100644 --- a/plugins/org.eclipaint.editor/src/org/eclipaint/editor/ImageEditor.java +++ b/plugins/org.eclipaint.editor/src/org/eclipaint/editor/ImageEditor.java @@ -192,16 +192,26 @@ private void createToolItems(ToolBar toolBar) { currentColorToolItem.setToolTipText("Current color"); // initialize color selection - // get first non transparent one + // get first completely non-transparent color for (PixelItem item : pixels) { if (item.alpha == 255) { colorPickerSelection = (PixelItem) item.clone(); break; } } - // if not found, get the first color + // get first non-transparent color + for (PixelItem item : pixels) { + if (item.alpha != 0) { + colorPickerSelection = (PixelItem) item.clone(); + break; + } + } + // if not found, get black if (colorPickerSelection == null) { - colorPickerSelection = (PixelItem) pixels.get(0).clone(); + PixelItem pixelItem = (PixelItem) pixels.get(0).clone(); + pixelItem.alpha = 255; + pixelItem.color = new RGB(0,0,0); + colorPickerSelection = pixelItem; } currentColorToolItem.setImage(EditorUtils.createImageForColorSelection(colorPickerSelection.color, colorPickerSelection.alpha));