Toggle navigation
Toggle navigation
This project
Loading...
Sign in
flutter_package
/
dart_pdf
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
David PHAM-VAN
2021-09-01 08:48:13 -0300
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
31e6a1bc54a32773ef6d5a6b9a93f2e812c2082c
31e6a1bc
1 parent
5c49367a
Improve image decoding error messages
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
3 deletions
pdf/CHANGELOG.md
pdf/lib/src/widgets/image_provider.dart
pdf/CHANGELOG.md
View file @
31e6a1b
...
...
@@ -3,6 +3,7 @@
## 3.5.0
-
Add annotations
[
John Harris
]
-
Improve image decoding error messages
## 3.4.2
...
...
pdf/lib/src/widgets/image_provider.dart
View file @
31e6a1b
...
...
@@ -98,7 +98,11 @@ class MemoryImage extends ImageProvider {
PdfImageOrientation
?
orientation
,
double
?
dpi
,
})
{
final
decoder
=
im
.
findDecoderForData
(
bytes
)!;
final
decoder
=
im
.
findDecoderForData
(
bytes
);
if
(
decoder
==
null
)
{
throw
Exception
(
'Unable to guess the image type
${bytes.length}
bytes'
);
}
if
(
decoder
is
im
.
JpegDecoder
)
{
final
info
=
PdfJpegInfo
(
bytes
);
...
...
@@ -111,7 +115,12 @@ class MemoryImage extends ImageProvider {
);
}
final
info
=
decoder
.
startDecode
(
bytes
)!;
final
info
=
decoder
.
startDecode
(
bytes
);
if
(
info
==
null
)
{
throw
Exception
(
'Unable decode the image'
);
}
return
MemoryImage
.
_
(
bytes
,
info
.
width
,
...
...
@@ -138,7 +147,12 @@ class MemoryImage extends ImageProvider {
return
PdfImage
.
file
(
context
.
document
,
bytes:
bytes
);
}
final
image
=
im
.
decodeImage
(
bytes
)!;
final
image
=
im
.
decodeImage
(
bytes
);
if
(
image
==
null
)
{
throw
Exception
(
'Unable decode the image'
);
}
final
resized
=
im
.
copyResize
(
image
,
width:
width
);
return
PdfImage
.
fromImage
(
context
.
document
,
image:
resized
);
}
...
...
Please
register
or
login
to post a comment