我想在XML文件中插入采保费费率的相关文件的图片,怎样才能实现

15:57 提问
java 怎么配置xml,将下面代码的图片链接换到xml里去
package com.
import java.io.F
import java.awt.image.BufferedI
import javax.imageio.ImageIO;
public class image {
public static void main(String args[]) {
// 读取第一张图片
File fileOne = new File("E:\1.jpg");
BufferedImage ImageOne = ImageIO.read(fileOne);
int width = ImageOne.getWidth();// 图片宽度
int height = ImageOne.getHeight();// 图片高度
// 从图片中读取RGB
int[] ImageArrayOne = new int[width * height];
ImageArrayOne = ImageOne.getRGB(0, 0, width, height, ImageArrayOne,
0, width);
// 对第二张图片做相同的处理
File fileTwo = new File("E:\2.jpg");
BufferedImage ImageTwo = ImageIO.read(fileTwo);
int[] ImageArrayTwo = new int[width * height];
ImageArrayTwo = ImageTwo.getRGB(0, 0, width, height, ImageArrayTwo,
0, width);
// 生成新图片
BufferedImage ImageNew = new BufferedImage(width * 2, height,
BufferedImage.TYPE_INT_RGB);
BufferedImage ImageNew = new BufferedImage(width, height*2,
BufferedImage.TYPE_INT_RGB);
ImageNew.setRGB(0, 0, width, height, ImageArrayOne, 0, width);// 设置左半部分的RGB
ImageNew.setRGB(width, 0, width, height, ImageArrayTwo, 0, width);// 设置右半部分的RGB
ImageNew.setRGB(0, height, width, ImageOne.getHeight()+ImageTwo.getHeight(), ImageArrayTwo, 0, width);// 设置右半部分的RGB
ImageNew.setRGB(0, height, width, height, ImageArrayTwo, 0, width);// 设置右半部分的RGB
System.out.println("已经合成图片");
File outFile = new File("E:\out.jpg");
ImageIO.write(ImageNew, "jpg", outFile);// 写图片
} catch (Exception e) {
e.printStackTrace();
按赞数排序
简单啊 用dom4j或者jdom解析xml 然后作为参数传递到你写的这个方法就OK了
示例:用的dom4j 下面mavendom4jdom4j1.6.1
file.xml 为配置文件(win 7
&?xml version="1.0" encoding="UTF-8"?&E:\1.jpgE:\2.jpgE:\out1.jpg
多了几行读代码的
SAXReader reader = new SAXReader();
Document document = reader.read(new File("E:\\file.xml"));
Element root = document.getRootElement();
Element file_first = root.element("file_first");
Element file_second = root.element("file_second");
Element file_out = root.element("file_out");
// 读取第一张图片
File fileOne = new File(file_first.getText());
BufferedImage ImageOne = ImageIO.read(fileOne);
int width = ImageOne.getWidth();// 图片宽度
int height = ImageOne.getHeight();// 图片高度
// 从图片中读取RGB
int[] ImageArrayOne = new int[width * height];
ImageArrayOne = ImageOne.getRGB(0, 0, width, height, ImageArrayOne,
0, width);
// 对第二张图片做相同的处理
File fileTwo = new File(file_second.getText());
BufferedImage ImageTwo = ImageIO.read(fileTwo);
int[] ImageArrayTwo = new int[width * height];
ImageArrayTwo = ImageTwo.getRGB(0, 0, width, height, ImageArrayTwo,
0, width);
// 生成新图片
// BufferedImage ImageNew = new BufferedImage(width * 2, height,
// BufferedImage.TYPE_INT_RGB);
BufferedImage ImageNew = new BufferedImage(width, height*2,
BufferedImage.TYPE_INT_RGB);
ImageNew.setRGB(0, 0, width, height, ImageArrayOne, 0, width);// 设置左半部分的RGB
// ImageNew.setRGB(width, 0, width, height, ImageArrayTwo, 0, width);// 设置右半部分的RGB
// ImageNew.setRGB(0, height, width, ImageOne.getHeight()+ImageTwo.getHeight(), ImageArrayTwo, 0, width);// 设置右半部分的RGB
ImageNew.setRGB(0, height, width, height, ImageArrayTwo, 0, width);// 设置右半部分的RGB
System.out.println("已经合成图片");
File outFile = new File(file_out.getText());
ImageIO.write(ImageNew, "jpg", outFile);// 写图片
} catch (Exception e) {
e.printStackTrace();
示例:用的dom4j 下面maven
&dependency&
&groupId&dom4j&/groupId&
&artifactId&dom4j&/artifactId&
&version&1.6.1&/version&
&/dependency&
file.xml 为配置文件(win 7 平台)
&?xml version="1.0" encoding="UTF-8"?&
&file_first&E:\\1.jpg&/file_first&
&file_second&E:\\2.jpg&/file_second&
&file_out&E:\\out1.jpg&/file_out&
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!
其他相关推荐XML如何插入图片_百度知道
XML如何插入图片
&?xml version=&1.0& encoding=&UTF-8&?&
&mainmenu&
&title&&![CDATA[ABOUT &font color=&#ffffff&&V&7font&&font color=&#BE0A29&&3&/font&]]&&/title&
&content_menu&&![CDATA[jieshao.jpg
&font color=&#ffffff& size=&15&&&a href=&h...
我有更好的答案求助知道网友
图片?当然是 &img src=&jieshao.jpg & /&
你用什么解析这个xml文件?你用的是自定义的Schema?你想要做什么?
本回答被提问者采纳
1条折叠回答
为您推荐:
其他类似问题
插入图片的相关知识
换一换
回答问题,赢新手礼包
个人、企业类
违法有害信息,请在下方选择后提交
色情、暴力
我们会通过消息、邮箱等方式尽快将举报结果通知您。xml没有图片,怎样实现在xsl中加入图片?_百度知道
xml没有图片,怎样实现在xsl中加入图片?
我有更好的答案
在xml中加节点 在节点的url属性上赋给图片路径
采纳率:45%
afdddddddddddddd
为您推荐:
其他类似问题
您可能关注的内容
换一换
回答问题,赢新手礼包
个人、企业类
违法有害信息,请在下方选择后提交
色情、暴力
我们会通过消息、邮箱等方式尽快将举报结果通知您。在android中的xml里怎么布置在一个图片上显示文字_百度知道
在android中的xml里怎么布置在一个图片上显示文字
我有更好的答案
采用RelativeLayout或FrameLayout都可以实现比如:&RelativeLayout
android:layout_width=&match_parent&
android:layout_height=&match_parent&
&ImageView
android:id=&@+id/img&
android:layout_width=&match_parent&
android:layout_height=&match_parent&
android:src=&@drawable/add& /&
android:layout_width=&match_parent&
android:layout_height=&wrap_content&
android:layout_alignParentBottom=&true&
android:gravity=&center&
android:textColor=&@color/black&
&/RelativeLayout&ImageView和TextView是重叠显示的
采纳率:48%
看你用什么控件了,比如 像button这样的可以给个background为图片然后button上面写文字,也可以达成你说的效果。
本回答被网友采纳
可以用FrameLayout来实现。在FrameLayout控件中用ImageView和TextView就能实现上面的效果。(RelativeLayout也能实现,方法和FrameLayout基本一样)
将图片设置为背景,如何添加文字在上面
图片可以经过PS等工具处理,将文字添加上去就成了啊。
其他2条回答
为您推荐:
其他类似问题
android的相关知识
换一换
回答问题,赢新手礼包
个人、企业类
违法有害信息,请在下方选择后提交
色情、暴力
我们会通过消息、邮箱等方式尽快将举报结果通知您。}

我要回帖

更多关于 采保费费率的相关文件 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信