iOS Question Image from Control?

Nicolás Cieri

Active Member
Licensed User
Hi, is possible to get and image from Control.. for example for all the content on a B4XView? Like a screenshoot of the control?.

Thanks..
 

Semen Matusovskiy

Well-Known Member
Licensed User
Probably there is better solution, but you can try following function (returns Bitmap):
B4X:
#If OBJC
- (UIImage *) getViewScreenShot : (UIView *) view
    {   
    UIGraphicsBeginImageContextWithOptions (view.frame.size, NO, 0.0);
    [view.layer renderInContext: UIGraphicsGetCurrentContext ()];
    UIImage * image = UIGraphicsGetImageFromCurrentImageContext ();
    UIGraphicsEndImageContext ();
    return image;
    }
#End If
If you want opaque image, use YES instead of NO.

Examples:
B4X:
    Dim noMe As NativeObject = Me
    ImageView1.Bitmap = noMe.RunMethod ("getViewScreenShot:", Array (Button1))
    ImageView2.Bitmap = noMe.RunMethod ("getViewScreenShot:", Array (B4XFloatTextField1.mBase))
 
Upvote 0

Nicolás Cieri

Active Member
Licensed User
Hi, this Snapshot is not working... any idea? Thanks

B4X:
    Dim b As B4XView = pnlRo   
    Dim avc As ActivityViewController
    avc.Initialize("avc", Array("Shared with you.", b.Snapshot))
    Dim mp As Page = B4XPages.GetNativeParent(Me)
    avc.Show(mp, pnl) 'Second parameter is relevant for iPad only. The arrow will point to the view.
 
Upvote 0

Nicolás Cieri

Active Member
Licensed User
Ok, the "Snapshot" method works, what does not work is being able to attach text and image via WhatsApp.

Should I start another question for that?
 
Upvote 0
Top