MCPcopy Create free account
hub / github.com/AstroImageJ/astroimagej / getBufferedImage

Method getBufferedImage

ij/src/main/java/ij/gui/Plot.java:2131–2164  ·  view source on GitHub ↗
(int width, int height)

Source from the content-addressed store, hash-verified

2129 }
2130
2131 @AstroImageJ(reason = "Support scaled plots")
2132 public BufferedImage getBufferedImage(int width, int height) {
2133 if (isAijPlot()) {
2134 draw();
2135
2136 var buffer = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
2137 var bufferGraphics = buffer.createGraphics();
2138
2139 if (VectorPlotDrawing.SCALED_PLOT.orElse(true)) {
2140 bufferGraphics.scale(Prefs.getGuiScale(), Prefs.getGuiScale());
2141 }
2142
2143 bufferGraphics.setColor(Color.WHITE);
2144 bufferGraphics.fillRect(0, 0, width, height);
2145
2146 var vectorPlotDrawing = new VectorPlotDrawing(this);
2147 vectorPlotDrawing.drawVectorForm(bufferGraphics);
2148
2149 bufferGraphics.dispose();
2150
2151 return buffer;
2152 }
2153
2154 // MP has a race condition as setSize sets the ip to null, and it disposes of the plot as well
2155 // So, make a copy of the plot and draw there
2156 var ip = getProcessor();
2157 if (ip == null) {
2158 var p = duplicate();
2159 p.draw();
2160 ip = p.getProcessor();
2161 }
2162
2163 return ip.getBufferedImage();
2164 }
2165
2166 /** Creates the processor if not existing, clears the background and prepares
2167 * it for plotting. Also called by the PlotWindow class to prepare the window. */

Callers 2

getTransferDataMethod · 0.45
writeImageMethod · 0.45

Calls 10

isAijPlotMethod · 0.95
drawMethod · 0.95
getGuiScaleMethod · 0.95
drawVectorFormMethod · 0.95
getProcessorMethod · 0.95
duplicateMethod · 0.95
fillRectMethod · 0.80
setColorMethod · 0.65
scaleMethod · 0.45
disposeMethod · 0.45

Tested by

no test coverage detected