Java Code Examples for java.awt.image.BufferedImage

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project android-joedayz, under directory /Proyectos/spring-rest-servidor/src/main/java/com/mycompany/rest/controller/.

Source file: PersonController.java

  39 
vote

@RequestMapping(value="/person/{id}",method=RequestMethod.GET,headers="Accept=image/jpeg, image/jpg, image/png, image/gif") public @ResponseBody byte[] getPhoto(@PathVariable("id") Long id){
  try {
    InputStream is=this.getClass().getResourceAsStream("/bella.jpg");
    BufferedImage img=ImageIO.read(is);
    ByteArrayOutputStream bao=new ByteArrayOutputStream();
    ImageIO.write(img,"jpg",bao);
    logger.debug("Retrieving photo as byte array image");
    return bao.toByteArray();
  }
 catch (  IOException e) {
    logger.error(e);
    throw new RuntimeException(e);
  }
}
 

Example 2

From project BioMAV, under directory /Behavior/src/nl/ru/ai/projects/parrot/tools/.

Source file: TwitterAccess.java

  37 
vote

/** 
 * Returns a RenderedImage object from a byte array
 * @param cameraOutput The camera output to transform into a RenderedImage
 * @return The RenderedImage that resulted from the camera output
 */
private RenderedImage getImageFromCamera(byte[] cameraOutput){
  BufferedImage image=new BufferedImage(VideoPollInterface.FRONT_VIDEO_FRAME_WIDTH,VideoPollInterface.FRONT_VIDEO_FRAME_HEIGHT,BufferedImage.TYPE_3BYTE_BGR);
  if (cameraOutput != null) {
    WritableRaster raster=Raster.createBandedRaster(DataBuffer.TYPE_BYTE,VideoPollInterface.FRONT_VIDEO_FRAME_WIDTH,VideoPollInterface.FRONT_VIDEO_FRAME_HEIGHT,3,new Point(0,0));
    raster.setDataElements(0,0,VideoPollInterface.FRONT_VIDEO_FRAME_WIDTH,VideoPollInterface.FRONT_VIDEO_FRAME_HEIGHT,cameraOutput);
    image.setData(raster);
  }
  return image;
}
 

Example 3

From project agile, under directory /agile-web/src/main/java/org/headsupdev/agile/web/.

Source file: CachedImageResource.java

  36 
vote

synchronized protected byte[] getImageData(){
  CachedResource cached=getCachedResource();
  if (cached != null) {
    return cached.getData();
  }
  BufferedImage img=new BufferedImage(getWidth(),getHeight(),BufferedImage.TYPE_INT_RGB);
  Graphics g=img.createGraphics();
  renderImage(g);
  byte[] data=toImageData(img);
  resources.add(new CachedResource(getParameters(),new Date(),data));
  return data;
}
 

Example 4

From project Agot-Java, under directory /src/main/java/got/ui/update/.

Source file: Util.java

  36 
vote

public static Image copyImage(final BufferedImage img,final boolean needAlpha){
  final BufferedImage copy=createImage(img.getWidth(),img.getHeight(),needAlpha);
  final Graphics2D g=(Graphics2D)copy.getGraphics();
  g.drawImage(img,0,0,null);
  g.dispose();
  return copy;
}
 

Example 5

From project ajah, under directory /ajah-image/src/main/java/com/ajah/image/.

Source file: AutoCrop.java

  36 
vote

/** 
 * Crops an image based on the value of the top left pixel.
 * @param data The image data.
 * @param fuzziness The fuzziness allowed for minor deviations (~5 is recommended).
 * @return The new image data, cropped.
 * @throws IOException If the image could not be read.
 */
public static byte[] autoCrop(final byte[] data,final int fuzziness) throws IOException {
  final BufferedImage image=ImageIO.read(new ByteArrayInputStream(data));
  final BufferedImage cropped=autoCrop(image,fuzziness);
  final ByteArrayOutputStream out=new ByteArrayOutputStream();
  ImageIO.write(cropped,"png",out);
  return out.toByteArray();
}
 

Example 6

From project appdriver, under directory /android/src/com/google/android/testing/nativedriver/client/.

Source file: AndroidNativeDriver.java

  36 
vote

/** 
 * {@inheritDoc}<p>Unlike most  {@link RemoteWebDriver} operations, this implementationdoes not send a request to the remote server. The screenshot is taken by using ADB on the driver client side to query the device.
 * @throws AdbException if an error occurred while driving the device throughthe  {@code adb} tool
 */
@Override public <X>X getScreenshotAs(OutputType<X> target) throws AdbException {
  AdbConnection adb=validateAdbConnection();
  FrameBufferFormat format=FrameBufferFormat.ofDevice(adb);
  BufferedImage screenImage=new BufferedImage(format.getXResolution(),format.getYResolution(),BufferedImage.TYPE_INT_ARGB);
  Process pullFrameBuffer=adb.pullFile(FrameBufferFormat.FB_DEVICEFILE);
  InputStream frameBufferStream=pullFrameBuffer.getInputStream();
  format.copyFrameBufferToImage(frameBufferStream,screenImage);
  AdbConnection.exhaustProcessOutput(frameBufferStream);
  Closeables.closeQuietly(frameBufferStream);
  AdbConnection.confirmExitValueIs(0,pullFrameBuffer);
  String base64Png=imageToBase64Png(screenImage);
  return target.convertFromBase64Png(base64Png);
}
 

Example 7

From project aranea, under directory /core/src/test/java/no/dusken/aranea/util/.

Source file: TestImageUtils.java

  36 
vote

@Test public void testResize() throws Exception {
  File originalFile=new File("src/test/resources/testImage.jpg");
  assertTrue("Could not read test image",originalFile.exists() && originalFile.canRead());
  File newFile=imageUtils.resizeImage(originalFile,20,30);
  BufferedImage newImage=ImageIO.read(newFile);
  assertEquals("Width is wrong",20,newImage.getWidth());
  assertEquals("Height is wrong",20,newImage.getHeight());
  newFile=imageUtils.resizeImage(originalFile,30,25);
  newImage=ImageIO.read(newFile);
  assertEquals("Width is wrong",25,newImage.getWidth());
  assertEquals("Height is wrong",25,newImage.getHeight());
  newFile.delete();
}
 

Example 8

From project arquillian-graphene, under directory /graphene-selenium/graphene-selenium-impl/src/main/java/org/jboss/arquillian/ajocado/framework/.

Source file: TypedSeleniumImpl.java

  36 
vote

private BufferedImage decodeBase64Screenshot(String screenshotInBase64){
  byte[] screenshotPng=Base64.decodeBase64(screenshotInBase64);
  ByteArrayInputStream inputStream=new ByteArrayInputStream(screenshotPng);
  BufferedImage result;
  try {
    result=ImageIO.read(inputStream);
  }
 catch (  IOException e) {
    throw new RuntimeException(e);
  }
  return result;
}
 

Example 9

From project arquillian-rusheye, under directory /rusheye-api/src/main/java/org/jboss/rusheye/suite/.

Source file: Mask.java

  36 
vote

/** 
 * Checks if is pixel masked.
 * @param pattern the pattern
 * @param x the x
 * @param y the y
 * @return true, if is pixel masked
 */
public boolean isPixelMasked(BufferedImage pattern,int x,int y){
  final BufferedImage maskImage=getMaskImage();
  int patternWidth=pattern.getWidth();
  int patternHeight=pattern.getHeight();
  int maskWidth=maskImage.getWidth();
  int maskHeight=maskImage.getHeight();
  int maskX=this.horizontalAlign == HorizontalAlign.LEFT ? x : x - (patternWidth - maskWidth);
  int maskY=this.verticalAlign == VerticalAlign.TOP ? y : y - (patternHeight - maskHeight);
  if (maskX < 0 || maskX >= maskWidth || maskY < 0 || maskY >= maskHeight) {
    return false;
  }
  return (maskImage.getRGB(maskX,maskY) & ALPHA_MASK) != 0;
}
 

Example 10

From project autopsy, under directory /Core/src/org/sleuthkit/autopsy/corecomponents/.

Source file: ThumbnailViewNode.java

  36 
vote

private static BufferedImage toBufferedImage(Image src){
  int w=src.getWidth(null);
  int h=src.getHeight(null);
  int type=BufferedImage.TYPE_INT_RGB;
  BufferedImage dest=new BufferedImage(w,h,type);
  Graphics2D g2=dest.createGraphics();
  g2.drawImage(src,0,0,null);
  g2.dispose();
  return dest;
}
 

Example 11

From project b3log-latke, under directory /latke/src/main/java/org/b3log/latke/image/local/.

Source file: LocalImageService.java

  36 
vote

/** 
 * Splices the specified image1 and image2 horizontally.
 * @param image1 the specified image1
 * @param image2 the specified image2
 * @return the spliced image
 */
private static BufferedImage splice(final java.awt.Image image1,final java.awt.Image image2){
  final int[][] size={{image1.getWidth(null),image1.getHeight(null)},{image2.getWidth(null),image2.getHeight(null)}};
  final int width=size[0][0] + size[1][0];
  final int height=Math.max(size[0][1],size[1][1]);
  final BufferedImage ret=new BufferedImage(width,height,BufferedImage.TYPE_INT_RGB);
  final Graphics2D g2=ret.createGraphics();
  g2.drawImage(image1,0,0,null);
  g2.drawImage(image2,size[0][0],0,null);
  return ret;
}
 

Example 12

From project Battlepath, under directory /src/interaction/.

Source file: BFrame.java

  36 
vote

public BFrame(Dimension size){
  super("Battlepath");
  GLProfile glp=GLProfile.getDefault();
  GLProfile.initSingleton();
  GLCapabilities caps=new GLCapabilities(glp);
  canvas=new GLCanvas(caps);
  setSize(size.width,size.height);
  add(canvas);
  addWindowListener(new ExitListener());
  setVisible(true);
  BufferedImage cursorImg=new BufferedImage(16,16,BufferedImage.TYPE_INT_ARGB);
  Cursor blankCursor=Toolkit.getDefaultToolkit().createCustomCursor(cursorImg,new Point(0,0),"blank cursor");
  canvas.setCursor(blankCursor);
}
 

Example 13

From project BDSup2Sub, under directory /src/main/java/bdsup2sub/gui/main/.

Source file: MainFrameView.java

  36 
vote

/** 
 * Update all components belonging to the source window
 * @param index caption index
 */
void refreshSrcFrame(final int index){
  SwingUtilities.invokeLater(new Runnable(){
    @Override public void run(){
      BufferedImage img=Core.getSrcImage();
      jPanelSource.setImage(img);
      jLabelInfoSource.setText(Core.getSrcInfoStr(index));
    }
  }
);
}
 

Example 14

From project Briss, under directory /src/main/java/at/laborg/briss/model/.

Source file: ClusterImageData.java

  36 
vote

private static BufferedImage scaleImage(BufferedImage bsrc,int width,int height){
  BufferedImage bdest=new BufferedImage(width,height,BufferedImage.TYPE_BYTE_GRAY);
  Graphics2D g=bdest.createGraphics();
  AffineTransform at=AffineTransform.getScaleInstance((double)bdest.getWidth() / bsrc.getWidth(),(double)bdest.getHeight() / bsrc.getHeight());
  g.drawRenderedImage(bsrc,at);
  g.dispose();
  return bdest;
}
 

Example 15

From project capedwarf-blue, under directory /images/src/main/java/org/jboss/capedwarf/images/.

Source file: CompositeImageBuilder.java

  36 
vote

private void paintComposite(Graphics2D g2,BufferedImage canvas,CompositeWrapper composite){
  BufferedImage image=getBufferedImage(composite);
  int x=getAnchorX(composite,canvas,image) + composite.getXOffset();
  int y=getAnchorY(composite,canvas,image) + composite.getYOffset();
  g2.drawImage(image,x,y,null);
}
 

Example 16

From project Carolina-Digital-Repository, under directory /djatoka-cdr/src/gov/lanl/adore/djatoka/.

Source file: DjatokaExtractProcessor.java

  36 
vote

/** 
 * Extract region or resolution level from JPEG 2000 image file.
 * @param input input absolute file path for input file.
 * @param os OutputStream to serialize formatted output image to.
 * @param params DjatokaDecodeParam instance containing region and transform settings.
 * @param w format writer to be used to serialize extracted region.
 * @throws DjatokaException
 */
public void extractImage(InputStream input,OutputStream os,DjatokaDecodeParam params,IWriter w) throws DjatokaException {
  BufferedImage bi=extractImpl.process(input,params);
  if (bi != null) {
    if (params.getScalingFactor() != 1.0 || params.getScalingDimensions() != null)     bi=applyScaling(bi,params);
    if (params.getTransform() != null)     bi=params.getTransform().run(bi);
    w.write(bi,os);
  }
}
 

Example 17

From project ceres, under directory /ceres-glayer/src/test/java/com/bc/ceres/glayer/jaitests/.

Source file: PlanarImageTest.java

  36 
vote

private static RenderedOp createTiledAndCachedImage(){
  final BufferedImage image=new BufferedImage(512,512,BufferedImage.TYPE_INT_ARGB);
  final ImageLayout imageLayout=new ImageLayout();
  imageLayout.setTileWidth(128);
  imageLayout.setTileHeight(128);
  final RenderingHints hints=new RenderingHints(JAI.KEY_IMAGE_LAYOUT,imageLayout);
  hints.add(new RenderingHints(JAI.KEY_TILE_CACHE,JAI.getDefaultInstance().getTileCache()));
  return FormatDescriptor.create(image,image.getSampleModel().getDataType(),hints);
}
 

Example 18

From project ChkBugReport, under directory /src/com/sonyericsson/chkbugreport/traceview/.

Source file: TreePNGPlugin.java

  36 
vote

private void createEmptyChart(Chart chart){
  BufferedImage img=new BufferedImage(W,H,BufferedImage.TYPE_INT_RGB);
  Graphics2D g=(Graphics2D)img.getGraphics();
  g.setColor(Color.BLACK);
  g.fillRect(0,0,W,H);
  chart.img=img;
  chart.g=g;
}
 

Example 19

From project CIShell, under directory /core/org.cishell.utilities/src/org/cishell/utilities/.

Source file: ImageUtilities.java

  36 
vote

public static BufferedImage createBufferedImageFilledWithColor(Color fillColor){
  BufferedImage bufferedImage=new BufferedImage(TEMPORARY_IMAGE_WIDTH,TEMPORARY_IMAGE_HEIGHT,BufferedImage.TYPE_INT_RGB);
  Graphics2D bufferedImageGraphics2D=bufferedImage.createGraphics();
  bufferedImageGraphics2D.setBackground(fillColor);
  return bufferedImage;
}
 

Example 20

From project citrus-sample, under directory /archetype-webx-quickstart/src/main/resources/archetype-resources/src/main/java/app1/module/screen/simple/.

Source file: SayHiImage.java

  36 
vote

private void writeImage(OutputStream out) throws IOException {
  BufferedImage img=new BufferedImage(800,600,BufferedImage.TYPE_INT_RGB);
  Graphics2D g2d=img.createGraphics();
  g2d.setPaint(Color.red);
  g2d.setFont(new Font("Serif",Font.BOLD,36));
  g2d.drawString("Hi there, how are you doing today?",5,g2d.getFontMetrics().getHeight());
  g2d.dispose();
  ImageIO.write(img,"jpg",out);
}
 

Example 21

From project Clotho-Core, under directory /ClothoApps/PluginManager/src/org/clothocore/tool/pluginmanager/gui/.

Source file: ChoosePreferredViewers.java

  36 
vote

private BufferedImage createReflectedPicture(BufferedImage avatar){
  int avatarWidth=avatar.getWidth();
  int avatarHeight=avatar.getHeight();
  BufferedImage alphaMask=createGradientMask(avatarWidth,avatarHeight);
  return createReflectedPicture(avatar,alphaMask);
}
 

Example 22

From project 16Blocks, under directory /src/main/java/de/minestar/sixteenblocks/Number/.

Source file: NumberUnit.java

  35 
vote

private void loadFromBitmap(){
  try {
    BufferedImage img=ImageIO.read(new File(Core.getInstance().getDataFolder(),"numbers.png"));
    int startX=this.number * 7;
    Color thisColor;
    int thisWidth=0;
    for (int y=0; y < img.getHeight(); y++) {
      int nowX=0;
      for (int x=startX; x < startX + 7; x++) {
        thisColor=new Color(img.getRGB(x,y));
        if (y == 0) {
          if (thisColor.getRed() != 255) {
            thisWidth++;
          }
        }
        if (thisColor.getGreen() == 255) {
          this.addBlock(-nowX,img.getHeight() - y - 1,35,(byte)15);
        }
 else         if (thisColor.getBlue() == 255) {
          this.addBlock(-nowX,img.getHeight() - y - 1,35,(byte)8);
        }
        nowX++;
        if (thisColor.getRed() == 255) {
          nowX--;
        }
      }
    }
    this.setWidth(thisWidth);
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
}
 

Example 23

From project activiti-explorer, under directory /src/main/java/org/activiti/explorer/util/.

Source file: ImageUtil.java

  35 
vote

/** 
 * Resizes the given image (passed as  {@link InputStream}. If the image is smaller then the given maximum width or height, the image will be proportionally resized.
 */
public static InputStream smallify(InputStream imageInputStream,String mimeType,int maxWidth,int maxHeight){
  try {
    BufferedImage image=ImageIO.read(imageInputStream);
    int width=Math.min(image.getWidth(),maxWidth);
    int height=Math.min(image.getHeight(),maxHeight);
    Mode mode=Mode.AUTOMATIC;
    if (image.getHeight() > maxHeight) {
      mode=Mode.FIT_TO_HEIGHT;
    }
    if (width != image.getWidth() || height != image.getHeight()) {
      image=Scalr.resize(image,mode,width,height);
    }
    ByteArrayOutputStream bos=new ByteArrayOutputStream();
    ImageIO.write(image,Constants.MIMETYPE_EXTENSION_MAPPING.get(mimeType),bos);
    return new ByteArrayInputStream(bos.toByteArray());
  }
 catch (  IOException e) {
    LOGGER.log(Level.SEVERE,"Exception while resizing image",e);
    return null;
  }
}
 

Example 24

From project ANNIS, under directory /annis-gui/src/main/java/annis/gui/visualizers/iframe/tree/.

Source file: TigerTreeVisualizer.java

  35 
vote

@Override public void writeOutput(VisualizerInput input,OutputStream outstream){
  this.input=input;
  AnnisResult result=input.getResult();
  List<AbstractImageGraphicsItem> layouts=new LinkedList<AbstractImageGraphicsItem>();
  double width=0;
  double maxheight=0;
  for (  DirectedGraph<AnnisNode,Edge> g : graphtools.getSyntaxGraphs(input)) {
    ConstituentLayouter<AbstractImageGraphicsItem> cl=new ConstituentLayouter<AbstractImageGraphicsItem>(g,backend,labeler,styler,input);
    AbstractImageGraphicsItem item=cl.createLayout(new LayoutOptions(VerticalOrientation.TOP_ROOT,AnnisGraphTools.detectLayoutDirection(result.getGraph())));
    Rectangle2D treeSize=item.getBounds();
    maxheight=Math.max(maxheight,treeSize.getHeight());
    width+=treeSize.getWidth();
    layouts.add(item);
  }
  BufferedImage image=new BufferedImage((int)(width + (layouts.size() - 1) * TREE_DISTANCE + 2 * SIDE_MARGIN),(int)(maxheight + 2 * TOP_MARGIN),BufferedImage.TYPE_INT_ARGB);
  Graphics2D canvas=createCanvas(image);
  double xOffset=SIDE_MARGIN;
  for (  AbstractImageGraphicsItem item : layouts) {
    AffineTransform t=canvas.getTransform();
    Rectangle2D bounds=item.getBounds();
    canvas.translate(xOffset,TOP_MARGIN + maxheight - bounds.getHeight());
    renderTree(item,canvas);
    xOffset+=bounds.getWidth() + TREE_DISTANCE;
    canvas.setTransform(t);
  }
  try {
    ImageIO.write(image,"png",outstream);
  }
 catch (  IOException e) {
    throw new RuntimeException(e);
  }
}
 

Example 25

From project blogs, under directory /request-mappers/src/main/java/com/wicketinaction/requestmappers/resources/images/.

Source file: ImageResourceReference.java

  35 
vote

/** 
 * Generates an image with a label. For real life application this method will read the image bytes from  external source.
 * @param label the image text to render
 * @return
 */
private byte[] getImageAsBytes(String label){
  BufferedImage image=new BufferedImage(800,600,BufferedImage.TYPE_INT_RGB);
  Graphics2D g=(Graphics2D)image.getGraphics();
  g.setColor(Color.BLACK);
  g.setBackground(Color.WHITE);
  g.clearRect(0,0,image.getWidth(),image.getHeight());
  g.setFont(new Font("SansSerif",Font.PLAIN,48));
  g.drawString(label,50,50);
  g.dispose();
  Iterator<ImageWriter> writers=ImageIO.getImageWritersByFormatName("jpg");
  ImageWriter writer=writers.next();
  if (writer == null) {
    throw new RuntimeException("JPG not supported?!");
  }
  final ByteArrayOutputStream out=new ByteArrayOutputStream();
  byte[] imageBytes=null;
  try {
    ImageOutputStream imageOut=ImageIO.createImageOutputStream(out);
    writer.setOutput(imageOut);
    writer.write(image);
    imageOut.close();
    imageBytes=out.toByteArray();
  }
 catch (  IOException e) {
    e.printStackTrace();
  }
  return imageBytes;
}
 

Example 26

From project brut.apktool, under directory /apktool-lib/src/main/java/brut/androlib/res/decoder/.

Source file: Res9patchStreamDecoder.java

  35 
vote

public void decode(InputStream in,OutputStream out) throws AndrolibException {
  try {
    byte[] data=IOUtils.toByteArray(in);
    BufferedImage im=ImageIO.read(new ByteArrayInputStream(data));
    int w=im.getWidth(), h=im.getHeight();
    BufferedImage im2=new BufferedImage(w + 2,h + 2,BufferedImage.TYPE_4BYTE_ABGR);
    if (im.getType() == BufferedImage.TYPE_4BYTE_ABGR) {
      im2.getRaster().setRect(1,1,im.getRaster());
    }
 else {
      im2.getGraphics().drawImage(im,1,1,null);
    }
    NinePatch np=getNinePatch(data);
    drawHLine(im2,h + 1,np.padLeft + 1,w - np.padRight);
    drawVLine(im2,w + 1,np.padTop + 1,h - np.padBottom);
    int[] xDivs=np.xDivs;
    for (int i=0; i < xDivs.length; i+=2) {
      drawHLine(im2,0,xDivs[i] + 1,xDivs[i + 1]);
    }
    int[] yDivs=np.yDivs;
    for (int i=0; i < yDivs.length; i+=2) {
      drawVLine(im2,0,yDivs[i] + 1,yDivs[i + 1]);
    }
    ImageIO.write(im2,"png",out);
  }
 catch (  IOException ex) {
    throw new AndrolibException(ex);
  }
}
 

Example 27

From project CBCJVM, under directory /cbc/CBCJVM/src/cbctools/image/.

Source file: ConvertImage.java

  35 
vote

public static void main(String[] args) throws IOException {
  System.out.println("CBCJVM Image Converter Tool - Version 0.0.1");
  if (args.length < 2) {
    System.out.println("Usage: ");
    System.out.println("\tjava cbctools.image.ConvertImage <source> <destination>");
    return;
  }
  OutputStream out=new FileOutputStream(new File(args[1]));
  DataOutputStream dOut=new DataOutputStream(out);
  BufferedImage image=ImageIO.read(new File(args[0]));
  dOut.writeInt(image.getWidth());
  for (int iy=0; iy < image.getHeight(); ++iy) {
    for (int ix=0; ix < image.getWidth(); ++ix) {
      dOut.writeInt(image.getRGB(ix,iy));
    }
  }
  System.out.println("Success! Wrote the image " + args[0] + " ("+ image.getWidth()+ ", "+ image.getHeight()+ ")");
  System.out.println("to " + args[1]);
}
 

Example 28

From project chukwa, under directory /src/main/java/org/apache/hadoop/chukwa/hicc/.

Source file: ImageSlicer.java

  35 
vote

public BufferedImage prepare(String filename){
  try {
    src=ImageIO.read(new File(filename));
  }
 catch (  IOException e) {
    log.error("Image file does not exist:" + filename + ", can not render image.");
  }
  XYData fullSize=new XYData(1,1);
  while (fullSize.getX() < src.getWidth() || fullSize.getY() < src.getHeight()) {
    fullSize.set(fullSize.getX() * 2,fullSize.getY() * 2);
  }
  float scaleX=(float)fullSize.getX() / src.getWidth();
  float scaleY=(float)fullSize.getY() / src.getHeight();
  log.info("Image size: (" + src.getWidth() + ","+ src.getHeight()+ ")");
  log.info("Scale size: (" + scaleX + ","+ scaleY+ ")");
  AffineTransform at=AffineTransform.getScaleInstance(scaleX,scaleY);
  AffineTransformOp op=new AffineTransformOp(at,AffineTransformOp.TYPE_BILINEAR);
  BufferedImage dest=op.filter(src,null);
  return dest;
}
 

Example 29

From project ciel-java, under directory /examples/Mandelbrot/src/java/skywriting/examples/mandelbrot/.

Source file: Mandelbrot.java

  35 
vote

public Mandelbrot(int tWidth,int tHeight,int maxit,double scale,int tOffX,int tOffY){
  this.tWidth=tWidth;
  this.tHeight=tHeight;
  this.maxit=maxit;
  this.scale=scale;
  this.tOffX=tOffX;
  this.tOffY=tOffY;
  p=new BufferedImage(tWidth,tHeight,BufferedImage.TYPE_3BYTE_BGR);
  g=p.getGraphics();
}