Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
appinventor-sources
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
appinventor-sources
Commits
e1122b90
Unverified
Commit
e1122b90
authored
Apr 15, 2020
by
Ramanathi
Committed by
GitHub
Apr 15, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement high-res download blocks PNG (#2152)
parent
70eb697c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
3 deletions
+14
-3
appinventor/blocklyeditor/src/exportBlocksImage.js
appinventor/blocklyeditor/src/exportBlocksImage.js
+14
-3
No files found.
appinventor/blocklyeditor/src/exportBlocksImage.js
View file @
e1122b90
...
@@ -304,6 +304,7 @@ function PNG() {
...
@@ -304,6 +304,7 @@ function PNG() {
* @const
* @const
*/
*/
PNG
.
HEADER
=
[
0x89
,
0x50
,
0x4E
,
0x47
,
0x0D
,
0x0A
,
0x1A
,
0x0A
];
PNG
.
HEADER
=
[
0x89
,
0x50
,
0x4E
,
0x47
,
0x0D
,
0x0A
,
0x1A
,
0x0A
];
var
pHY_data
=
[
0x00
,
0x00
,
0x16
,
0x25
,
0x00
,
0x00
,
0x16
,
0x25
,
0x01
];
/**
/**
* Chunk represents the four components of a PNG file chunk.
* Chunk represents the four components of a PNG file chunk.
...
@@ -461,13 +462,23 @@ Blockly.exportBlockAsPng = function(block) {
...
@@ -461,13 +462,23 @@ Blockly.exportBlockAsPng = function(block) {
img
.
src
=
uri
;
img
.
src
=
uri
;
img
.
onload
=
function
()
{
img
.
onload
=
function
()
{
var
canvas
=
document
.
createElement
(
'
canvas
'
);
var
canvas
=
document
.
createElement
(
'
canvas
'
);
canvas
.
width
=
img
.
width
;
canvas
.
width
=
2
*
img
.
width
;
canvas
.
height
=
img
.
height
;
canvas
.
height
=
2
*
img
.
height
;
var
context
=
canvas
.
getContext
(
'
2d
'
);
var
context
=
canvas
.
getContext
(
'
2d
'
);
context
.
drawImage
(
img
,
0
,
0
);
context
.
drawImage
(
img
,
0
,
0
,
img
.
width
,
img
.
height
,
0
,
0
,
canvas
.
width
,
canvas
.
height
);
function
download
(
png
)
{
function
download
(
png
)
{
png
.
setCodeChunk
(
code
);
png
.
setCodeChunk
(
code
);
for
(
var
i
=
0
;
i
<
png
.
chunks
.
length
;
i
++
)
{
var
phy
=
[
112
,
72
,
89
,
115
];
if
(
png
.
chunks
[
i
].
type
==
'
pHYs
'
)
{
png
.
chunks
.
splice
(
i
,
1
,
new
PNG
.
Chunk
(
9
,
'
pHYs
'
,
pHY_data
,
crc32
(
phy
.
concat
(
pHY_data
))));
//replacing existing pHYs chunk
break
;
}
else
if
(
png
.
chunks
[
i
].
type
==
'
IDAT
'
)
{
png
.
chunks
.
splice
(
i
,
0
,
new
PNG
.
Chunk
(
9
,
'
pHYs
'
,
pHY_data
,
crc32
(
phy
.
concat
(
pHY_data
))));
// adding new pHYs chunk
break
;
}
}
var
blob
=
png
.
toBlob
();
var
blob
=
png
.
toBlob
();
var
a
=
document
.
createElement
(
'
a
'
);
var
a
=
document
.
createElement
(
'
a
'
);
a
.
download
=
(
block
.
getChildren
().
length
===
0
?
block
.
type
:
'
blocks
'
)
+
'
.png
'
;
a
.
download
=
(
block
.
getChildren
().
length
===
0
?
block
.
type
:
'
blocks
'
)
+
'
.png
'
;
...
...
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