Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: TBitmap error 'bitmap size too big' using createChooser and TMessageManager


This question is not answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 0
Roel Janssen

Posts: 1
Registered: 2/9/06
TBitmap error 'bitmap size too big' using createChooser and TMessageManager  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 8, 2018 10:52 AM
After converting my android app that processes images, and worked perfectly under XE6, to Tokyo 10.2.2, I do not get it to work anymore. The problem is isolated to, and demonstrated by, the source below. It contains a simple fmx Form1 having a single Button1 and a Memo1 on it.

Problem: When trying to modify a TBitmap via TMessageResultNotification, this fails if android createChooser is used as intent for startActivityForResult and an image is actually chosen. MaxBitmapSize returns 0 and setting the Bitmap fails with error 'bitmap size too big'.

It works fine, if you use the chooser, but cancel (e.g. press back button) without actually picking an image. It also works fine if you do not use createChooser, demonstrated by just commenting out that line in the source below. But I want the chooser, because it disables the 'Always'-option of the image picker.

I thought of using TJIntent::JavaClass->createChooser(intent, StringToJString("Bitmap Test"), intentsender ) instead, but cannot get this _di_JIntendSender to work. Nor do I know if this would provide a solution to my problem.

All suggestions are appreciated!

SOURCE UNIT.CPP

TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
Bitmap = new TBitmap;
BitmapWidth = 90;
SubResultNote =
TMessageManager::DefaultManager->SubscribeToMessage(__classid(TMessageResultNotification),DoResultNote);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormDestroy(TObject *Sender)
{
TMessageManager::DefaultManager->Unsubscribe(__classid(TMessageResultNotification),SubResultNote);
delete Bitmap;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::DoResultNote( TObject* const obj, TMessageBase* msg)
{
Memo1->Lines->Add("thread maxbitmapsize "+IntToStr(Canvas->GetAttribute(TCanvasAttribute::MaxBitmapSize)));
try { Bitmap->SetSize(BitmapWidth+=10,100); }
catch(Exception &err) { Memo1->Lines->Add("bitmap error "+err.Message); }
Memo1->Lines->Add("bitmap width "+IntToStr(Bitmap->Width));
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
Memo1->Lines->Add("start maxbitmapsize "+IntToStr(Canvas->GetAttribute(TCanvasAttribute::MaxBitmapSize)));
_di_JIntent intent = TJIntent::JavaClass->init(TJIntent::JavaClass->ACTION_GET_CONTENT);
intent->setType(StringToJString("image/*"));
intent->addCategory(TJIntent::JavaClass->CATEGORY_OPENABLE);
// when selecting an image by the chooser, the link to the canvas max bitmap size is lost
// but if you cancel, or do not use the user (i.e. remove next line), then it works fine
intent = TJIntent::JavaClass->createChooser(intent, StringToJString("Bitmap Test") );
TAndroidHelper::Activity->startActivityForResult( intent, 123 );
}
//---------------------------------------------------------------------------
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02