gpt4 book ai didi

image - Blackberry - ListField 包含文件系统中的图像

转载 作者:行者123 更新时间:2023-12-01 22:43:31 25 4
gpt4 key购买 nike

我使用以下代码从手机或 SDCard 检索图像,并将该图像使用到我的 ListField 中。它给出了输出,但需要很长时间才能生成屏幕。如何解决这个问题呢 ??谁能帮我??提前致谢!!!

String text = fileholder.getFileName();
try{
String path="file:///"+fileholder.getPath()+text;
//path=”file:///SDCard/BlackBerry/pictures/image.bmp”

InputStream inputStream = null;
//Get File Connection
FileConnection fileConnection = (FileConnection) Connector.open(path);

inputStream = fileConnection.openInputStream();

ByteArrayOutputStream baos = new ByteArrayOutputStream();
int j = 0;
while((j=inputStream.read()) != -1) {
baos.write(j);
}
byte data[] = baos.toByteArray();
inputStream.close();
fileConnection.close();

//Encode and Resize image
EncodedImage eImage = EncodedImage.createEncodedImage(data,0,data.length);
int scaleFactorX = Fixed32.div(Fixed32.toFP(eImage.getWidth()),
Fixed32.toFP(180));
int scaleFactorY = Fixed32.div(Fixed32.toFP(eImage.getHeight()),
Fixed32.toFP(180));
eImage=eImage.scaleImage32(scaleFactorX, scaleFactorY);
Bitmap bitmapImage = eImage.getBitmap();
graphics.drawBitmap(0, y+1, 40, 40,bitmapImage, 0, 0);
graphics.drawText(text, 25, y,0,width);
}
catch(Exception e){}

最佳答案

您应该读取文件一次(在应用程序启动时或屏幕打开之前,也许在那里放置一个进度对话框),将图像放入数组中并在绘画中使用该数组。

关于image - Blackberry - ListField 包含文件系统中的图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2728788/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com