Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(android): add rotation to blob #13715

Merged
merged 11 commits into from
Aug 19, 2023
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;
m1ga marked this conversation as resolved.
Show resolved Hide resolved
}

@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
Loading