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
03d65ad7
Commit
03d65ad7
authored
Jul 17, 2012
by
Katie Laverty
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allowed ImageSprites to rotate and resize simultaneously
parent
6bb811bb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
2 deletions
+11
-2
appinventor/components/src/com/google/appinventor/components/runtime/ImageSprite.java
...om/google/appinventor/components/runtime/ImageSprite.java
+11
-2
No files found.
appinventor/components/src/com/google/appinventor/components/runtime/ImageSprite.java
View file @
03d65ad7
...
...
@@ -59,6 +59,7 @@ public class ImageSprite extends Sprite {
private
Bitmap
unrotatedBitmap
;
private
Bitmap
rotatedBitmap
;
private
Bitmap
scaledBitmap
;
private
BitmapDrawable
rotatedDrawable
;
private
double
cachedRotationHeading
;
...
...
@@ -95,15 +96,23 @@ public class ImageSprite extends Sprite {
// Rotate around the center of the sprite image (w/2, h/2)
// TODO(halabelson): Add a way for the user to specify the center of rotation.
mat
.
setRotate
((
float
)
-
Heading
(),
w
/
2
,
h
/
2
);
// We must scale the unrotated Bitmap to be the user specified size before
// rotating.
if
(
w
!=
unrotatedBitmap
.
getWidth
()
||
h
!=
unrotatedBitmap
.
getHeight
())
{
scaledBitmap
=
Bitmap
.
createScaledBitmap
(
unrotatedBitmap
,
w
,
h
,
true
);
}
else
{
scaledBitmap
=
unrotatedBitmap
;
}
// Next create the rotated bitmap
// Careful: We use getWidth and getHeight of the unrotated bitmap, rather than the
// Width and Height of the sprite. Doing the latter produces an illegal argument
// exception in creating the bitmap, if the user sets the Width or Height of the
// sprite to be larger than the image size.
rotatedBitmap
=
Bitmap
.
createBitmap
(
unrotat
edBitmap
,
scal
edBitmap
,
0
,
0
,
unrotatedBitmap
.
getWidth
(),
unrotat
edBitmap
.
getHeight
(),
scaledBitmap
.
getWidth
(),
scal
edBitmap
.
getHeight
(),
mat
,
true
);
// make a drawable for the rotated image and cache the heading
rotatedDrawable
=
new
BitmapDrawable
(
rotatedBitmap
);
...
...
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