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
2019-11-24 16:31:53 -0500
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
a290047505283b6d8a2cc876f1d533781889e015
a2900475
1 parent
ea098132
Add support for GreyScale Jpeg
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
5 deletions
pdf/CHANGELOG.md
pdf/lib/src/compatibility.dart
pdf/lib/src/exif.dart
pdf/lib/src/image.dart
pdf/CHANGELOG.md
View file @
a290047
...
...
@@ -16,6 +16,7 @@
-
Simplify PdfImage constructor
-
Implement Image orientation
-
Add Exif reader
-
Add support for GreyScale Jpeg
## 1.3.23
...
...
pdf/lib/src/compatibility.dart
View file @
a290047
...
...
@@ -205,6 +205,7 @@ class PDFImage extends PdfImage {
height:
height
,
alpha:
alpha
,
alphaChannel:
false
,
isRGB:
true
,
jpeg:
false
,
orientation:
PdfImageOrientation
.
topLeft
);
}
...
...
pdf/lib/src/exif.dart
View file @
a290047
...
...
@@ -24,6 +24,7 @@ class PdfJpegInfo {
int
width
;
int
height
;
int
color
;
int
offset
=
0
;
while
(
offset
<
buffer
.
lengthInBytes
)
{
while
(
buffer
.
getUint8
(
offset
)
==
0xff
)
{
...
...
@@ -55,6 +56,7 @@ class PdfJpegInfo {
if
(
mrkr
==
0xc0
)
{
height
=
buffer
.
getUint16
(
offset
+
1
);
width
=
buffer
.
getUint16
(
offset
+
3
);
color
=
buffer
.
getUint8
(
offset
+
5
);
break
;
}
offset
+=
len
-
2
;
...
...
@@ -62,15 +64,19 @@ class PdfJpegInfo {
final
Map
<
PdfExifTag
,
dynamic
>
tags
=
_findExifInJpeg
(
buffer
);
return
PdfJpegInfo
.
_
(
width
,
height
,
tags
);
return
PdfJpegInfo
.
_
(
width
,
height
,
color
,
tags
);
}
PdfJpegInfo
.
_
(
this
.
width
,
this
.
height
,
this
.
tags
);
PdfJpegInfo
.
_
(
this
.
width
,
this
.
height
,
this
.
_color
,
this
.
tags
);
final
int
width
;
final
int
height
;
final
int
_color
;
bool
get
isRGB
=>
_color
==
3
;
final
Map
<
PdfExifTag
,
dynamic
>
tags
;
/// EXIF version
...
...
pdf/lib/src/image.dart
View file @
a290047
...
...
@@ -51,6 +51,7 @@ class PdfImage extends PdfXObject {
height:
height
,
alpha:
alpha
,
alphaChannel:
false
,
isRGB:
true
,
jpeg:
false
,
orientation:
orientation
,
);
...
...
@@ -62,12 +63,14 @@ class PdfImage extends PdfXObject {
@required
int
height
,
@required
this
.
alpha
,
@required
this
.
alphaChannel
,
@required
this
.
isRGB
,
@required
this
.
jpeg
,
@required
this
.
orientation
,
})
:
assert
(
alphaChannel
==
false
||
alpha
==
true
),
assert
(
width
!=
null
),
assert
(
height
!=
null
),
assert
(
jpeg
!=
null
),
assert
(
isRGB
!=
null
),
assert
(
orientation
!=
null
),
_width
=
width
,
_height
=
height
,
...
...
@@ -86,16 +89,17 @@ class PdfImage extends PdfXObject {
height:
height
,
alpha:
alpha
,
alphaChannel:
true
,
isRGB:
false
,
jpeg:
jpeg
,
orientation:
orientation
,
);
params
[
'/SMask'
]
=
PdfStream
.
string
(
'
${_sMask.objser}
0 R'
);
}
if
(
alphaChannel
)
{
params
[
'/ColorSpace'
]
=
PdfStream
.
string
(
'/DeviceGray'
);
}
else
{
if
(
isRGB
)
{
params
[
'/ColorSpace'
]
=
PdfStream
.
string
(
'/DeviceRGB'
);
}
else
{
params
[
'/ColorSpace'
]
=
PdfStream
.
string
(
'/DeviceGray'
);
}
if
(
jpeg
)
{
...
...
@@ -118,6 +122,7 @@ class PdfImage extends PdfXObject {
height:
info
.
height
,
jpeg:
true
,
alpha:
false
,
isRGB:
info
.
isRGB
,
alphaChannel:
false
,
orientation:
orientation
??
info
.
orientation
,
);
...
...
@@ -145,6 +150,9 @@ class PdfImage extends PdfXObject {
/// The image data is a jpeg image
final
bool
jpeg
;
/// The image data is a color RGB image
final
bool
isRGB
;
/// The internal orientation of the image
final
PdfImageOrientation
orientation
;
...
...
Please
register
or
login
to post a comment