Get Static Map -> Img speichern, öffnen, anzeigen, get von mapquest

This commit is contained in:
2021-04-15 22:30:26 +02:00
parent 34aa390f2c
commit 39c4244668
11 changed files with 168 additions and 27 deletions

View File

@ -0,0 +1,32 @@
package tourplaner.business;
import java.awt.*;
import java.awt.image.BufferedImage;
public class ImgHelper {
/**
* Converts a given Image into a BufferedImage
*
* @param img The Image to be converted
* @return The converted BufferedImage
*/
public static BufferedImage toBufferedImage(Image img)
{
if (img instanceof BufferedImage)
{
return (BufferedImage) img;
}
// Create a buffered image with transparency
BufferedImage bimage = new BufferedImage(img.getWidth(null), img.getHeight(null), BufferedImage.TYPE_INT_ARGB);
// Draw the image on to the buffered image
Graphics2D bGr = bimage.createGraphics();
bGr.drawImage(img, 0, 0, null);
bGr.dispose();
// Return the buffered image
return bimage;
}
}