我试图将此代码从.NET转换为Java,但我无法转换这4行。请有人给我一个如何转换此代码的建议:
this.pbSubSequence = (Image) new Bitmap(this.pbSubSequence.getWidth(),
this.pbSubSequence.getHeight());
Image image = this.pbSubSequence.Image;
Graphics graphics = Graphics.FromImage(this.pbSubSequence.Image);
(pbSubSequence
是一个小组;我在这段代码中有四个小组,我必须在所有四个小组中绘制ecg的图形,这将通过以下方式完成:
g.draw(new Line2D.Float(100f,100f,500f,500f)
(此行将在for
循环中运行)
有人可以帮我用Java编写这些行吗?
答案 0 :(得分:1)
答案 1 :(得分:0)
那天我尝试了这段代码,我几乎得到了我想要的东西
BufferedImage image=new BufferedImage(pbSubsequence.getWidth(), pbSubsequence.getHeight(), BufferedImage.TYPE_3BYTE_BGR);
JLabel l=new JLabel(new ImageIcon(image));
Graphics graphics = image.getGraphics();
Graphics2D g = (Graphics2D) graphics;
pbSubsequence.add(l);
其中pbSubsequence是一个JPanel.So我能够将代码从.net转换为java.Still左边的测试部分,所以无法确定答案是否正确。谢谢大家帮忙