Skip to content

Commit

Permalink
feat(android): add rotation to blob (#13715)
Browse files Browse the repository at this point in the history
  • Loading branch information
m1ga committed Aug 19, 2023
1 parent 0f82b8f commit 8d51e09
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public class TiBlob extends KrollProxy
private int height;
private int uprightWidth;
private int uprightHeight;
private Object rotation;

// This handles the memory cache of images.
private final TiBlobLruCache mMemoryCache = TiBlobLruCache.getInstance();
Expand All @@ -74,6 +75,7 @@ private TiBlob(int type, Object data, String mimetype)
this.height = 0;
this.uprightWidth = 0;
this.uprightHeight = 0;
this.rotation = KrollRuntime.UNDEFINED;
}

/**
Expand Down Expand Up @@ -239,6 +241,7 @@ public void loadBitmapInfo()
this.height = opts.outHeight;

int rotation = getImageOrientation();
this.rotation = rotation;
if ((rotation == 90) || (rotation == 270)) {
this.uprightWidth = opts.outHeight;
this.uprightHeight = opts.outWidth;
Expand Down Expand Up @@ -411,6 +414,12 @@ public int getUprightWidth()
return this.uprightWidth;
}

@Kroll.getProperty
public Object getRotation()
{
return this.rotation;
}

@Kroll.getProperty
public int getSize()
{
Expand Down
7 changes: 7 additions & 0 deletions apidoc/Titanium/Blob.yml
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,13 @@ properties:
since: {android: "7.2.0", iphone: "0.9.0", ipad: "0.9.0", macos: "9.2.0"}
permission: read-only

- name: rotation
type: Number
summary: EXIF rotation of the image if available. Can be `undefined` if no orientation was found.
platforms: [android]
since: {android: "12.3.0"}
permission: read-only

methods:
- name: toString
returns:
Expand Down

0 comments on commit 8d51e09

Please sign in to comment.