I have an ArrayList
as a member variable of a class which should be intialized with a bitmap object when the function, OnImageDecodeUrlReceived()
and the whole list should be used in another function, OnCreate()
later. But since the bitmap objects are local to OnImageDecodeUrlReceived()
, the object gets out of scope and wont be available in OnCreate()
.
How to make the bitmap objects visible outside the function?
Asked
Active
Viewed 172 times
0

Eduard Florinescu
- 16,747
- 28
- 113
- 179

Rohith Murali
- 5,551
- 2
- 25
- 26
-
You could construct a new `Bitmap` that is a copy of the received one, and add the copy to the `ArrayList`. – Michael Nov 12 '13 at 13:19
-
I tried to do that by using 'new Bitmap(oldBitmapObject)' but it seems to generate an error saying 'cannot call a private constructor'. Please specify if there's any other method. – Rohith Murali Nov 14 '13 at 11:16
-
I mean using the `Construct` method. Refer to [the documentation for `Bitmap`](https://developer.tizen.org/help/index.jsp?topic=%2Forg.tizen.native.apireference%2FclassTizen_1_1Graphics_1_1Bitmap.html) – Michael Nov 14 '13 at 12:06
2 Answers
0
You need to store the bitmap pointers in the arraylist ,Don't delete the pointers within OnImageDecodeUrlReceived()
Eg:
Define arrayList as
ArrayListT<Bitmap*> yourList;
void YourClass::OnImageDecodeUrlReceived(RequestId reqId,
Tizen::Graphics::Bitmap* pBitmap, result r,
const Tizen::Base::String errorCode,
const Tizen::Base::String errorMessage)
{
yourList.Add(pBitmap);
}
Clear the arrayList and delete those bitmap pointers after use

Viswanath Lekshmanan
- 9,945
- 1
- 40
- 64
-
Still I cant display the images from the ArrayListT! When the image is loaded to a Bitmap* object at OnCreate() using GetAt(index,bitmapObject) the application closes unexpectedly. – Rohith Murali Nov 18 '13 at 12:47
-
Is bitmap object a local variable of the OnImageDecodeUrlReceived()? If that's so, the objects must be loosing scope and should get deleted automatically after the scope of the function. In that case what can be done to make same bitmap image extend its scope? – Rohith Murali Nov 18 '13 at 13:36
-
You should look in to the pointer handling, Bitmap* will not loose its scope unless you delete the pointer, you should keep pointers it in the arrayList, could you post your code , including arrayList.add get declaration and usage – Viswanath Lekshmanan Nov 19 '13 at 18:52
0
I created array of Bitmap objects(not pointer objects) in the class and later copied the Bitmap in OnImageDecodeUrlReceived() to those objects in array using Construct. Now it works fine.

Rohith Murali
- 5,551
- 2
- 25
- 26