How to access an image stored in Blackberry using Bitmap.getBitmapResource ()?

I want to access an image stored in Blackberry, for example, in the folder "store / home / user / image.png".

Now I can access this image as

String filePath = "file:///store/home/user/image.png;
Bitmap image = Bitmap.getBitmapResource(filePath);
BitmapField bitmapField = new BitmapField(image, BitmapField.FOCUSABLE);

OR

I need to access it,

  String filePath = "file:///store/home/user/image.png;
  FileConnection fconn = (FileConnection)Connector.open(filePath, Connector.READ); 
  if (fconn.exists()) 
  {
                ........
                ........                           

     input.close();
     fconn.close();                            

  }

I can access the image using the second method, but I want to know if I can access the image using "Bitmap.getBitmapResource (filePath)"?

+3
source share
3 answers

Take a look at the Bitmap.getBitmapResource API Link:

public static Bitmap getBitmapResource ( )
.
cod, .
:
name - .
:
Bitmap null, .
:
NullPointerException - NULL.

JDE 3.6

public static Bitmap getBitmapResource (String module, String name)
, .
:
module - , -. , > .
name - .
:
Bitmap null, .
:
NullPointerException - NULL.

JDE 3.6

. - , .

- , FileConnection, MIME, EncodedImage.

+4

Bitmap.getBitmapResource() , COD COD, . , .

JavaDocs

+3

What language do you write? Here's how I did it in C ++ on Windows Mobile:

Log::GetSingleton() << "Loading sprite: " << wchar_path << "\n";

// Special magic WM bitmap loading function that isn't in the examples
// because Microsoft wants you to use resource files
HBITMAP bitmap = SHLoadDIBitmap(wchar_path);

if (!bitmap) 
{
    Error::LastError();
    Error::Explain("Failed to load bitmap.");
    return NULL;
}

HDC dc_image = CreateCompatibleDC(NULL);
if (!dc_image) 
{
    Error::LastError();
    Error::Explain("Failed to create memory device context.");
    return NULL;
}
HBITMAP other_bitmap = (HBITMAP)SelectObject(dc_image, bitmap);

wchar_pathwill be something like \\Storage Card\\test.bmp.

-2
source

Source: https://habr.com/ru/post/1721175/


All Articles