Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
E
esc_pos_print_plus
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Dio Maulana
esc_pos_print_plus
Commits
fad5484c
Commit
fad5484c
authored
Sep 02, 2019
by
Andrey
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
printImage: image flipped horizontally; width bug fixed ; create a copy of image before processing.
parent
ee7610bc
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
7 deletions
+11
-7
example.dart
example/example.dart
+3
-0
printer.dart
lib/src/printer.dart
+8
-7
No files found.
example/example.dart
View file @
fad5484c
...
...
@@ -48,7 +48,10 @@ void main() {
const
String
filename
=
'./logo.png'
;
final
Image
image
=
decodeImage
(
File
(
filename
).
readAsBytesSync
());
// Print image
printer
.
printImage
(
image
);
// Print image (using an outdated command)
// printer.printImageRaster(image);
printer
.
cut
();
printer
.
disconnect
();
...
...
lib/src/printer.dart
View file @
fad5484c
...
...
@@ -318,7 +318,8 @@ class Printer {
/// Print image using GS v 0 (obsolete command)
///
/// [image] is an instanse of class from [Image library](https://pub.dev/packages/image)
void
printImageRaster
(
Image
image
)
{
void
printImageRaster
(
Image
imgSrc
)
{
final
Image
image
=
Image
.
from
(
imgSrc
);
// make a copy
const
bool
highDensityHorizontal
=
true
;
const
bool
highDensityVertical
=
true
;
...
...
@@ -359,27 +360,27 @@ class Printer {
/// Print image using ESC *
///
/// [image] is an instanse of class from [Image library](https://pub.dev/packages/image)
void
printImage
(
Image
image
)
{
void
printImage
(
Image
imgSrc
)
{
final
Image
image
=
Image
.
from
(
imgSrc
);
// make a copy
const
bool
highDensityHorizontal
=
true
;
const
bool
highDensityVertical
=
true
;
invert
(
image
);
flip
(
image
,
Flip
.
horizontal
);
final
Image
imageRotated
=
copyRotate
(
image
,
270
);
// TODO(Andrey): Mirror image (FLIP_LEFT_RIGHT)
const
int
lineHeight
=
highDensityVertical
?
3
:
1
;
final
List
<
List
<
int
>>
blobs
=
_toColumnFormat
(
imageRotated
,
lineHeight
*
8
);
print
(
blobs
.
length
);
print
(
blobs
[
0
].
length
);
final
int
widthPx
=
imageRotated
.
width
;
final
int
heightPx
=
imageRotated
.
height
;
const
int
densityByte
=
(
highDensityHorizontal
?
1
:
0
)
+
(
highDensityVertical
?
32
:
0
);
// header = ESC + b"*" + six.int2byte(density_byte) + _int_low_high(width_pixels, 2)
final
List
<
int
>
header
=
List
.
from
(
cBitImg
.
codeUnits
);
header
.
add
(
densityByte
);
header
.
addAll
(
_intLowHigh
(
width
Px
,
2
));
header
.
addAll
(
_intLowHigh
(
height
Px
,
2
));
// Adjust line spacing (for 16-unit line feeds): ESC 3 0x10 (HEX: 0x1b 0x33 0x10)
sendRaw
([
27
,
51
,
16
]);
...
...
@@ -398,7 +399,7 @@ class Printer {
final
int
widthPx
=
image
.
width
;
final
int
heightPx
=
image
.
height
;
int
left
=
0
;
List
<
List
<
int
>>
blobs
=
[];
final
List
<
List
<
int
>>
blobs
=
[];
int
i
=
0
;
// TODO(Andrey): We lose a part of image here -> use while(left < widthPx)
...
...
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