在 BlackBerry 上显示缩放图像
我的 BlackBerry 应用程序应从 Web 服务获取图像并将该图像显示为缩略图。谁能给我一个关于如何实现这一目标的想法?
My BlackBerry application should fetch an image from a web service and display the image as a thumbnail. Can anyone give me an idea on how to achieve this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
petteri关于使用EncodedImage和scaleImage32()的说法是正确的。具体来说,您需要将
createEncodedImage(byte[] data, int offset, int length)
与 Web 服务返回的字节一起使用。请注意,scaleImage32 采用“int”参数,但它们是定点数,与更广为人知的浮点数不同。要获取所需的定点值,请使用 Fixed32
最后,如果您不需要 BlackBerry 应用程序中的原始图像,如果 Web 服务进行缩放,您将获得更好的整体体验。这将减少传输到设备的字节数,并且减少设备上缩放图像所需的计算量。服务器上的缩放也可能会产生更高质量的缩放图像,因为scaleImage32() 使用相当基本的算法。
petteri is right about using EncodedImage and scaleImage32(). Specifically, you'll want to use
createEncodedImage(byte[] data, int offset, int length)
with the bytes returned by the webservice.Be aware that scaleImage32 takes 'int' arguments, but they are fixed-point numbers, in contrast to the more widely known floating-point numbers. To get the fixed-point value you want, use the utility methods in Fixed32
Finally, if you don't need the original image in the BlackBerry application, you will have a better overall experience if the webservice does the scaling. This will reduce the number of bytes transferred to the device, and it will reduce the computation done on device to scale the image. Scaling on the server will likely result in a higher quality scaled image as well, as scaleImage32() uses a fairly basic algorithm.
我也不完全熟悉 BB,但由于没有其他人回答您的问题,请查看 EncodedImage 类,其中方法 scaleImage32() 应该返回缩放后的版本。
I'm not totally familiar with BB either but since nobody else is answering your question, check out EncodedImage class and there method scaleImage32() should return you the scaled version.
此代码可以帮助您
这将从您的 Web 服务 url 生成字节数组。这里 bb 是字节数组。
BB 中有两个处理图像的类。
EncodedImage
和Bitmap
都有从字节数组生成图像的构造函数。我建议使用位图,它具有轻松调整图像大小的功能。This code can help you
This will generate Byte Array from your web service url. here
bb
is byte array.There are two classes that handles image in BB.
EncodedImage
andBitmap
, both have constructors that generate image from byte array. I recommend use Bitmap, it has easy image re size capability.