我正在尝试使用Java开发某种绘画.
我有一个位于JPanel内的JComponent.
我已经可以在该JComponent中绘制线条和矩形.
现在,我如何将这些图纸导出为图像(png,gif,jpg)?
我试过这个:
BufferedImage b = new BufferedImage(1700,1100,BufferedImage.TYPE_INT_RGB);
this.print(getGraphics());
try{ImageIO.write(b,"png",new File("test.png"));}catch (Exception e) {}
Run Code Online (Sandbox Code Playgroud)
但这只会创建一个全黑的.png文件.
救命!!!
解决!!!
BufferedImage bi = new BufferedImage(this.getSize().width, this.getSize().height, BufferedImage.TYPE_INT_ARGB);
Graphics g = bi.createGraphics();
this.paint(g); //this == JComponent
g.dispose();
try{ImageIO.write(bi,"png",new File("test.png"));}catch (Exception e) {}
Run Code Online (Sandbox Code Playgroud) 我对nokogiri的宝石有这个问题:
无法打开库'C:\ Ruby187\lib\ruby\gems\1.8\gems \nokogiri-1.4.6-x86-mingw32\ext \nokogiri\libxml2.dll':未知
我读到我必须尝试1.5.0.beta3版本.但是,当我跑
C:\Users\t3en4>gem install nokogiri --pre
Fetching: nokogiri-1.5.0.beta.4.gem (100%)
ERROR: Error installing nokogiri:
The 'nokogiri' native gem requires installed build tools.
Please update your PATH to include build tools or download the DevKit
from 'http://rubyinstaller.org/downloads' and follow the instructions
at 'http://github.com/oneclick/rubyinstaller/wiki/Development-Kit'
Run Code Online (Sandbox Code Playgroud)
我该怎么办?
可以在HTML5的画布中添加元素吗?
例如:
<canvas id="canvas2" width="650" height="850">
<div class="draggable" class="ui-widget-content" width='100px' height='100px'>
<textarea class="resizable" rows="2" cols="10" style="color: #FF0707; ">
Example
</textarea>
</div>
</canvas>
Run Code Online (Sandbox Code Playgroud)
这没有显示任何东西......但是,如果我把那个可拖动的div放在html中的任何其他元素中它可以工作......
我错过了什么?
谢谢.
我正在使用DevKit和XAMPP,现在我必须执行以下命令:
gem install mysql2 -v 0.2.6 --platform=ruby -- --with-mysql-dir="x:\Prog
ram Files\mysql-5.5.11-winx64" --with-mysql-lib="x:\Program Files\mysql-5.5.11-winx64\lib" --with-my
sql-include="x:\Program Files\mysql-5.5.11-winx64\include" --without-opt-dir
Run Code Online (Sandbox Code Playgroud)
但是,XAMPP 在其MySQL目录中不包含lib或include文件夹.我应该指定什么呢?
谢谢