使用JSR234实现对图片的缩放
来源:技术人生 责任编辑:栏目编辑 发表时间:2013-07-02 05:31 点击:次
使用JSR234实现对图片的缩放
关键字: jsr
JSR234是高级媒体API,在原有的MMA的基础 上增加了很多Control,目前nokia的s60第三版已经开始支持jsr234,他主要支持对图片、声音等多媒体信息的一些高级处理,下面是使用其对图片缩放的方法:3GEYEd4E w?d3ynf'h
3GEYE?g9}.A7n(P!RL
9I-wm"st@'H3 /** *//**
wy/Z+dp'G3 * 实现对图片的缩放3GEYE0L|7[r0S7o1z
* @param path String 缩放图片的路径
;k8U;e9R_!Q3 * @param newWidth int 新的宽度3GEYEM6boR;XsH
* @param newHeight int 新的高度3GEYE fo.r'Q$Y ]5eN/M:Q
* @return Image 缩放以后得到的Image对象
K,t nxnZ3 */3GEYE W4Bo!g&q9^ul`~5Pi/}
public Image zoomImage(String path,int newWidth,int newHeight)...{3GEYEj'?{3p9A%tV
Image re = null;
M%If*T!E+s+v3 MediaProcessor mp = null;
-k'@ QZ%Uh}q3 ByteArrayOutputStream baos = new ByteArrayOutputStream();3GEYEm+z @"xuT~
try ...{
S1W(OOG9e7@){3 mp = GlobalManager.createMediaProcessor("image/png");3GEYE0O4k*W6NGy b3qB
InputStream in = this.getClass().getResourceAsStream(path);
@\6q,e?YI*w"c'xq!p3 mp.setInput(in,MediaProcessor.UNKNOWN);
U"[^ yS2f3 mp.setOutput(baos);3GEYEo4L%m6Hw)[)JQb
ImageTransformControl itc = (ImageTransformControl)mp.getControl("javax.microedition.amms.control.imageeffect.ImageTransformControl");3GEYE Ag;n8M ]F L
int sw = itc.getSourceWidth();
-P)zXG8~(k,s3 int sh = itc.getSourceHeight();3GEYE\+a?\g#At C8o
int ow = newWidth;3GEYE G p qulF}
int oh = newHeight;
.iq/e;ViE7Z._$f3 itc.setSourceRect(0,0,sw,sh);
){X1]%[R r3D3 itc.setTargetSize(ow,oh,0);3GEYE}3by tvQ
itc.setEnabled(true);
.l i6^3|(D3 mp.start();
R$u;P$\A?e3 mp.complete();3GEYE9D6WE8j;w/f
byte b[] = baos.toByteArray();
.x[ B b/`_3 System.out.println(b.length);3GEYE@x8_Xh(F'Q
int[] ints = new int[b.length / 4];3GEYE ?iQ4P#bx
int intcount, bytecount;3GEYE*f+^O/^8_&?u@([
for (intcount = 0, bytecount = 0; bytecount < b.length; ) ...{3GEYEK9kMH)Hs x
ints[intcount] =3GEYEoI[+kK
(( ((int)(b[bytecount + 0])) << 24)
关键字: jsr
JSR234是高级媒体API,在原有的MMA的基础 上增加了很多Control,目前nokia的s60第三版已经开始支持jsr234,他主要支持对图片、声音等多媒体信息的一些高级处理,下面是使用其对图片缩放的方法:3GEYEd4E w?d3ynf'h
3GEYE?g9}.A7n(P!RL
9I-wm"st@'H3 /** *//**
wy/Z+dp'G3 * 实现对图片的缩放3GEYE0L|7[r0S7o1z
* @param path String 缩放图片的路径
;k8U;e9R_!Q3 * @param newWidth int 新的宽度3GEYEM6boR;XsH
* @param newHeight int 新的高度3GEYE fo.r'Q$Y ]5eN/M:Q
* @return Image 缩放以后得到的Image对象
K,t nxnZ3 */3GEYE W4Bo!g&q9^ul`~5Pi/}
public Image zoomImage(String path,int newWidth,int newHeight)...{3GEYEj'?{3p9A%tV
Image re = null;
M%If*T!E+s+v3 MediaProcessor mp = null;
-k'@ QZ%Uh}q3 ByteArrayOutputStream baos = new ByteArrayOutputStream();3GEYEm+z @"xuT~
try ...{
S1W(OOG9e7@){3 mp = GlobalManager.createMediaProcessor("image/png");3GEYE0O4k*W6NGy b3qB
InputStream in = this.getClass().getResourceAsStream(path);
@\6q,e?YI*w"c'xq!p3 mp.setInput(in,MediaProcessor.UNKNOWN);
U"[^ yS2f3 mp.setOutput(baos);3GEYEo4L%m6Hw)[)JQb
ImageTransformControl itc = (ImageTransformControl)mp.getControl("javax.microedition.amms.control.imageeffect.ImageTransformControl");3GEYE Ag;n8M ]F L
int sw = itc.getSourceWidth();
-P)zXG8~(k,s3 int sh = itc.getSourceHeight();3GEYE\+a?\g#At C8o
int ow = newWidth;3GEYE G p qulF}
int oh = newHeight;
.iq/e;ViE7Z._$f3 itc.setSourceRect(0,0,sw,sh);
){X1]%[R r3D3 itc.setTargetSize(ow,oh,0);3GEYE}3by tvQ
itc.setEnabled(true);
.l i6^3|(D3 mp.start();
R$u;P$\A?e3 mp.complete();3GEYE9D6WE8j;w/f
byte b[] = baos.toByteArray();
.x[ B b/`_3 System.out.println(b.length);3GEYE@x8_Xh(F'Q
int[] ints = new int[b.length / 4];3GEYE ?iQ4P#bx
int intcount, bytecount;3GEYE*f+^O/^8_&?u@([
for (intcount = 0, bytecount = 0; bytecount < b.length; ) ...{3GEYEK9kMH)Hs x
ints[intcount] =3GEYEoI[+kK
(( ((int)(b[bytecount + 0])) << 24)
相关新闻>>
- 发表评论
-
- 最新评论 更多>>