iOS Question cutting a part of a web page into another image

John Woodsmall

Active Member
Licensed User
Longtime User
I have a web page that displays fine. I need to cut a portion of it
and display it as an image. Also I do not want to display the web page
only the image that I have cut into an image.
 

John Woodsmall

Active Member
Licensed User
Longtime User
all i know is :

WebView2
.LoadUrl(target0)
i then display the page where webview2 is.
So if you don't mind can you show me the simple steps to get the web page into an image
that I can slice up and then show the image instead of the web page?

I asume that I can the routines you pointed to...but how?
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
This code saves the webview content to a bitmap:
B4X:
Sub WebView1_PageFinished (Success As Boolean, Url As String)
   If Success Then
     Dim iv As ImageView
     iv.Initialize("")
     iv.SetLayoutAnimated(0, 1, 0, 0, WebView1.Width, WebView1.Height)
     Dim cvs As Canvas
     cvs.Initialize(iv)
     cvs.DrawView(WebView1, cvs.TargetRect)
     cvs.Refresh
     Dim bmp As Bitmap = cvs.CreateBitmap
   End If
End Sub

Note that only the visible WebView content will be saved.
 
Upvote 0

John Woodsmall

Active Member
Licensed User
Longtime User
ok...i see...
now how do i
1.) slice the bmp (above) to match the "good_part" below
2.) display the sliced bmp into a page as an image?
 

Attachments

  • Whole_Page_Sent_Back.gif
    Whole_Page_Sent_Back.gif
    56 KB · Views: 359
  • Good_Part.gif
    Good_Part.gif
    13.1 KB · Views: 342
Upvote 0

John Woodsmall

Active Member
Licensed User
Longtime User
ok
so somehow i am ment to call the drawbitmap subrountine above?
from the webview1 sub above?
and the canvus will then apear on the page?
(as you can see I barely know the correct words to talk to you...but I am articulate in other lang.)
 
Upvote 0

John Woodsmall

Active Member
Licensed User
Longtime User
can you give me an example of a web page reached:WebView2.LoadUrl(target0)
and then a script that saves(optains it) to an image and then a script that cuts the image
as required and then displays that image to a page?

thanks!
 
Upvote 0
Top