/** * Generates an image for frame-image. * * @param backgroundColor background color. * @return An image data for frame. */ public ImageData create(HSB backgroundColor) { ImageData source = CoreImages.getImageDescriptor(CoreImages.FRAME).getImageData(); List<RGB> newRGBs = new ArrayList<RGB>(); for (RGB each : source.palette.colors) { try { HSB copy = backgroundColor.getCopy(); HSB hsb = new HSB(each); copy.brightness = hsb.brightness; copy = copy.mixWith(backgroundColor, 0.6f); newRGBs.add(copy.toRGB()); } catch (Exception e) { e.printStackTrace(); } } source.palette.colors = newRGBs.toArray(new RGB[newRGBs.size()]); return source; }
/** * @param height The height of drag handle to generate. * @param backgroundColor background color to generate drag handle. * @param embossed if <code>true</code> generated embossed drag handle, otherwise generated * engraved one. * @return Drag handle {@link ImageData}. */ public ImageData create(int height, HSB backgroundColor, boolean embossed) { ImageData source = null; if (embossed) { source = SharedImages.getImageDescriptor(SharedImages.HANDLE_EMBOSSED).getImageData(); } else { source = SharedImages.getImageDescriptor(SharedImages.HANDLE).getImageData(); } ImageData result = new ImageData(source.width, height, source.depth, source.palette); int offset = (result.height - source.height) / 2; for (int x = 0; x < result.width; x++) { for (int y = 0; y < result.height; y++) { if (y >= offset && y < offset + source.height) { result.setPixel(x, y, source.getPixel(x, y - offset)); } else { result.setPixel(x, y, source.transparentPixel); } } } result.transparentPixel = source.transparentPixel; List<RGB> newRGBs = new ArrayList<RGB>(); for (RGB each : result.palette.colors) { try { HSB hsb = backgroundColor.getCopy(); hsb.brightness = new HSB(each).brightness; hsb = hsb.mixWith(backgroundColor, 0.7f); newRGBs.add(hsb.toRGB()); } catch (Exception e) { e.printStackTrace(); } } result.palette.colors = newRGBs.toArray(new RGB[newRGBs.size()]); return result; }