Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
Flutter Inappwebview
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
李增强
Flutter Inappwebview
Commits
39788a01
Commit
39788a01
authored
Jun 24, 2019
by
Paulo Melo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Android takeScreenshot does not work properly.
parent
f6353b8f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
4 deletions
+12
-4
android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/InAppWebView/InAppWebView.java
...renzo/flutter_inappbrowser/InAppWebView/InAppWebView.java
+12
-4
No files found.
android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/InAppWebView/InAppWebView.java
View file @
39788a01
...
@@ -298,19 +298,27 @@ public class InAppWebView extends WebView {
...
@@ -298,19 +298,27 @@ public class InAppWebView extends WebView {
}
}
public
byte
[]
takeScreenshot
()
{
public
byte
[]
takeScreenshot
()
{
Picture
picture
=
capturePicture
();
float
scale
=
getScale
();
int
height
=
(
int
)
(
getContentHeight
()
*
scale
+
0.5
);
Bitmap
b
=
Bitmap
.
createBitmap
(
getWidth
(),
Bitmap
b
=
Bitmap
.
createBitmap
(
getWidth
(),
getHeight
()
,
Bitmap
.
Config
.
ARGB_8888
);
height
,
Bitmap
.
Config
.
ARGB_8888
);
Canvas
c
=
new
Canvas
(
b
);
Canvas
c
=
new
Canvas
(
b
);
picture
.
draw
(
c
);
draw
(
c
);
int
scrollOffset
=
(
getScrollY
()
+
getMeasuredHeight
()
>
b
.
getHeight
())
?
b
.
getHeight
()
:
getScrollY
();
Bitmap
resized
=
Bitmap
.
createBitmap
(
b
,
0
,
scrollOffset
,
b
.
getWidth
(),
getMeasuredHeight
());
ByteArrayOutputStream
byteArrayOutputStream
=
new
ByteArrayOutputStream
();
ByteArrayOutputStream
byteArrayOutputStream
=
new
ByteArrayOutputStream
();
b
.
compress
(
Bitmap
.
CompressFormat
.
PNG
,
100
,
byteArrayOutputStream
);
resized
.
compress
(
Bitmap
.
CompressFormat
.
PNG
,
100
,
byteArrayOutputStream
);
try
{
try
{
byteArrayOutputStream
.
close
();
byteArrayOutputStream
.
close
();
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
resized
.
recycle
();
return
byteArrayOutputStream
.
toByteArray
();
return
byteArrayOutputStream
.
toByteArray
();
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment