Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
yotta
/
pictogram
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
60
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
ad83e21c
authored
Mar 17, 2016
by
Fernando Martínez Santiago
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
PCB rescaling all pictos greater than 100dx width
parent
741bbc42
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
5 deletions
android/Pictogram/app/src/main/java/com/yottacode/pictogram/net/ImgDownloader.java
android/Pictogram/app/src/main/java/com/yottacode/pictogram/tools/Img.java
android/Pictogram/app/src/main/java/com/yottacode/tools/ImgTools.java
android/Pictogram/app/src/main/java/com/yottacode/pictogram/net/ImgDownloader.java
View file @
ad83e21c
...
...
@@ -78,7 +78,7 @@ public class ImgDownloader extends AsyncTask<Vector<Img>, Void, Img> {
File
file
=
new
File
(
img
.
get_url
());
is
=
new
FileInputStream
(
file
);
}
int
size
=
img
.
save_bitmap
(
this
.
context
,
is
,
this
.
source
==
source
.
local
);
int
size
=
img
.
save_bitmap
(
this
.
context
,
is
);
allsize
+=
size
;
i
++;
}
catch
(
IOException
e
)
{
...
...
android/Pictogram/app/src/main/java/com/yottacode/pictogram/tools/Img.java
View file @
ad83e21c
...
...
@@ -124,22 +124,26 @@ public class Img {
* @param is the stream where the image is available
* @throws IOException
*/
public
int
save_bitmap
(
Context
context
,
InputStream
is
,
boolean
resize
)
throws
IOException
{
public
int
save_bitmap
(
Context
context
,
InputStream
is
)
throws
IOException
{
final
float
MAX_WIDTH
=
100
;
File
file
=
file
(
context
);
FileOutputStream
os
=
new
FileOutputStream
(
file
);
try
{
this
.
bitmap
=
BitmapFactory
.
decodeStream
(
is
);
if
(
resize
)
this
.
bitmap
=
new
ImgTools
(
this
.
bitmap
).
resize
(
78
,
66
);
if
(
this
.
bitmap
.
getWidth
()>
MAX_WIDTH
)
{
this
.
bitmap
=
new
ImgTools
(
this
.
bitmap
).
rescale
(
MAX_WIDTH
/
(
float
)
this
.
bitmap
.
getWidth
());
}
}
catch
(
java
.
lang
.
OutOfMemoryError
err
)
{
Log
.
e
(
Img
.
class
.
getCanonicalName
(),
"Out of memory when decoding "
+
this
.
get_url
());
}
ByteArrayOutputStream
outstream
=
new
ByteArrayOutputStream
();
this
.
bitmap
.
setHasAlpha
(
true
);
this
.
bitmap
.
compress
(
Bitmap
.
CompressFormat
.
PNG
,
10
0
,
outstream
);
this
.
bitmap
.
compress
(
Bitmap
.
CompressFormat
.
PNG
,
5
0
,
outstream
);
byte
[]
byteArray
=
outstream
.
toByteArray
();
os
.
write
(
byteArray
);
outstream
.
close
();
os
.
close
();
System
.
gc
();
return
byteArray
.
length
;
}
...
...
android/Pictogram/app/src/main/java/com/yottacode/tools/ImgTools.java
View file @
ad83e21c
...
...
@@ -39,4 +39,11 @@ public class ImgTools {
// objeto drawable y así asignarlo a un botón, imageview...
return
resizedBitmap
;
}
public
Bitmap
rescale
(
float
scale
)
{
int
width
=
(
int
)
(
scale
*
(
float
)
this
.
bitmap
.
getWidth
());
int
height
=
(
int
)
(
scale
*
(
float
)
this
.
bitmap
.
getHeight
());
return
resize
(
width
,
height
);
}
}
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