java+android 图片处理问题

java+android 图片处理问题,第1张

public class CanvasTest extends Activity{

@Override

protected void onCreate(Bundle savedInstanceState) {

// TODO Auto-generated method stub

superonCreate(savedInstanceState);

setContentView(new MyView(this));

}

class MyView  extends View{

public MyView(Context context) {

super(context);

// TODO Auto-generated constructor stub

}

@Override

protected void onDraw(Canvas canvas) {

// TODO Auto-generated method stub

canvasdrawColor(ColorWHITE);  //设置白色画布

Paint paint =new Paint();//画笔

paintsetColor(ColorBLACK);

paintsetStyle(StyleFILL);

Bitmap bt=BitmapFactorydecodeResource(CanvasTestthisgetResources(), Rdrawablea);//要移动的

canvasdrawBitmap(bt, 50, 50, paint);//bt是 50  50 是的左上角坐标

superonDraw(canvas);

}

}

}

思路是这样具体需求自己该

等着拿分
import javaawtColor;
import javaawtFont;
import javaawtGraphics2D;
import javaawteventComponentAdapter;
import javaawteventComponentEvent;
import javaawtfontFontRenderContext;
import javaawtgeomRectangle2D;
import javaawtimageBufferedImage;
import javaioFile;
import javaioIOException;
import javaximageioImageIO;
/
@author alanwei

/
public class Test {

public static BufferedImage createImage(int width, int height, String s) {
Font font = new Font("Serif", FontBOLD, 10);
BufferedImage bi = new BufferedImage(width, height, BufferedImageTYPE_INT_RGB);
Graphics2D g2 = (Graphics2D)bigetGraphics();
g2setBackground(ColorWHITE);
g2clearRect(0, 0, width, height);
g2setPaint(ColorRED);

g2drawString(s, 0, 5 + height / 2);

return bi;
}

/
@param args
@throws IOException
/
public static void main(String[] args) throws IOException {
BufferedImage image = createImage(100, 20, "123456789");

File file = new File("imagejpg");
if (!fileexists()) {
filecreateNewFile();
}

if (image != null) {
ImageIOwrite(image, "jpg", file);
}
}
}

json串中肯定有的地址是吧,可以这样做
//资源
String url = ">ImageIcon iup= new ImageIcon(thisgetClass()getResource("upjpg"));
JButton up_button= new JButton("开始考试", iup);


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/13378460.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-07-24
下一篇 2023-07-24

发表评论

登录后才能评论

评论列表(0条)

保存