congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
Thumber$Pictures
Code IndexAdd Tabnine to your IDE (free)

How to use
Thumber$Pictures
in
com.atlassian.core.util.thumbnail

Best Java code snippets using com.atlassian.core.util.thumbnail.Thumber$Pictures (Showing top 2 results out of 315)

origin: com.atlassian.core/atlassian-core-thumbnail

public static BufferedImage toBufferedImage(Image image) {
  if (image instanceof BufferedImage) {
    return (BufferedImage) image;
  }
  // This code ensures that all the pixels in the image are loaded
  image = new ImageIcon(image).getImage();
  // Determine if the image has transparent pixels
  boolean hasAlpha = hasAlpha(image);
  // Create a buffered image using the default color model
  int type = hasAlpha ? BufferedImage.TYPE_INT_ARGB : BufferedImage.TYPE_INT_RGB;
  BufferedImage bimage = new BufferedImage(image.getWidth(null), image.getHeight(null), type);
  // Copy image to buffered image
  Graphics g = bimage.createGraphics();
  // Paint the image onto the buffered image
  g.drawImage(image, 0, 0, null);
  g.dispose();
  return bimage;
}
origin: com.atlassian.core/atlassian-core-thumbnail

/**
 * This method should take BufferedImage argument, but takes just Image for backward compatibility (so that the
 * client code can stay intact). Normally anyway a BufferedImage instance will be provided and the image will be
 * directly processed without transforming it to BufferedImage first.
 *
 * @param imageToScale  image to scale (BufferedImage is welcome, other image types will be transformed to
 *                      BufferedImage first)
 * @param newDimensions desired max. dimensions
 * @return scaled image
 */
public BufferedImage scaleImage(Image imageToScale, ThumbnailDimension newDimensions) {
  final BufferedImage sourceImage = Pictures.toBufferedImage(imageToScale);
  final Image scaledInstance = sourceImage.getScaledInstance(newDimensions.getWidth(), newDimensions.getHeight(), Image.SCALE_SMOOTH);
  final BufferedImage bufferedScaledImage = new BufferedImage(newDimensions.getWidth(), newDimensions.getHeight(),
      Pictures.hasAlpha(imageToScale) ? BufferedImage.TYPE_INT_ARGB : BufferedImage.TYPE_INT_RGB);
  final Graphics graphics = bufferedScaledImage.getGraphics();
  try {
    graphics.drawImage(scaledInstance, 0, 0, null);
  } finally {
    graphics.dispose();
  }
  return bufferedScaledImage;
}
com.atlassian.core.util.thumbnailThumber$Pictures

Javadoc

Code based on http://www.dreamincode.net/code/snippet1076.htm Looks like public domain The change:

I don't use screen-compatible image creation - I assume JIRA runs in headless mode anyway

Most used methods

  • hasAlpha
  • toBufferedImage

Popular in Java

  • Running tasks concurrently on multiple threads
  • getApplicationContext (Context)
  • setScale (BigDecimal)
  • getResourceAsStream (ClassLoader)
  • GridLayout (java.awt)
    The GridLayout class is a layout manager that lays out a container's components in a rectangular gri
  • Collection (java.util)
    Collection is the root of the collection hierarchy. It defines operations on data collections and t
  • Annotation (javassist.bytecode.annotation)
    The annotation structure.An instance of this class is returned bygetAnnotations() in AnnotationsAttr
  • FileUtils (org.apache.commons.io)
    General file manipulation utilities. Facilities are provided in the following areas: * writing to a
  • StringUtils (org.apache.commons.lang)
    Operations on java.lang.String that arenull safe. * IsEmpty/IsBlank - checks if a String contains
  • Option (scala)
  • Top plugins for Android Studio
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now