Copyright (c) Nikolaj Baer
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
1. ...
If you think the Android project android-jplay listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code
package com.nikolajbaer.awtrender;
/*fromwww.java2s.com*/import com.nikolajbaer.render.RenderObject;
import com.nikolajbaer.render.Renderable;
import java.awt.*;
import java.awt.geom.*;
import java.awt.image.*;
publicclass PNGRenderObject extends AWTRenderObject {
private Image m_image;
privatefinalstatic Color CLEAR=new Color(0,0,0,0);
public PNGRenderObject(String pngFile){
// TODO load pngFile
Toolkit toolkit = Toolkit.getDefaultToolkit();
// TODO add try/except
m_image = toolkit.getImage(pngFile);
}
publicvoid renderFromWorld(float x,float y,float a){
int w=m_image.getWidth(null);
int h=m_image.getHeight(null);
//System.out.println("I am "+w+"x"+h+" pixels, or "+(w/m_pixelsPerMeter)+"x"+(h/m_pixelsPerMeter)+ " meters");
m_graphics.translate(x*m_pixelsPerMeter,y*m_pixelsPerMeter);
m_graphics.rotate(a);
m_graphics.drawImage(m_image,-w/2,-h/2,null);
//m_graphics.setColor(Color.RED);
//m_graphics.drawOval(-w/2,-h/2,w,h);
}
}