使用GameCanvas从byte []数组绘制图像 [英] DrawImage from byte[] array using GameCanvas
本文介绍了使用GameCanvas从byte []数组绘制图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
DrawImage
,有可能吗?
服务器发送jpg图片,该图片存储在byte[]
array
中,如何显示?
我看过关于从int[]
array
绘制的图片,其中每个元素都是RGB颜色,
就我而言,我需要对图像拳头进行解码.
请帮忙.
DrawImage
from byte[]
array using GameCanvas, is it possible?
Server sends jpg-image, which stores in byte[]
array
, how to display it?
I have seen about drawing from int[]
array
, where each element is RGB color,
by in my case I need to decode image fist.
Please, help.
edit:
try{
os.write(data);//send request to server
Thread.sleep(200);
while(is.available()==0)//wait
{
}
slen = 96860;
byte[] img = new byte[96860];
is.read(img, 0, slen);// read image into array
Image image = Image.createImage(img,0,slen);// creating image
g.drawImage(image, // <== illegal argument exception
0,
0,
100);
}
catch(Exception x){
System.out.print(x.toString());
}
在Debug中,我看到图像的大小和内容,并且在使用ImageItem和form.append ..时此方法有效,但是在Canvas中-它不起作用.
in Debug i see image size and content, and this method works when use ImageItem and form.append.. , but in Canvas - it not works.
推荐答案
您的问题与最后一个参数"100"一起使用.在JSR-118文档中阅读锚点.锚参数仅允许使用某些值,而100不是其中之一.所需的任何值都应以大写形式表示,例如Graphics.HCENTER | Graphics.TOP
[提示:如果您想回复此内容,请不要再发表另一个答案",请对此发表评论.如果您喜欢此答案,请对其投票并标记为已接受".谢谢.
Your problem is with the last argument "100". Read up on anchor points in the JSR-118 documentation. There are only certain values allowed for the anchor argument, and 100 is not one of them. Whatever value you want should be expressed sumbolically, for exampleGraphics.HCENTER | Graphics.TOP
[Hint: if you want to reply to this, don''t post another ''Answer'', make a comment to this one. If you like this answer, vote for it and mark it ''accepted''. Thanks.
< b&s; sadsadas</b>
< b> sad< b>/b" sa</b>
dsa
dsa
dsa
dsa
dsa
dsa
爸爸
伤心
asd
<b>sadsadas</b>
<b>sad<b></b>sa</b>
dsa
dsa
dsa
dsa
dsa
dsa
dad
sad
asd
这篇关于使用GameCanvas从byte []数组绘制图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文