05-14-2022 11:32 - edited 05-14-2022 17:08
05-14-2022 11:32 - edited 05-14-2022 17:08
Hi! I'm trying to put a png image on watch, but I can't... on Fitbit OS Simulator works like a charm, but not on watch...
What I'm doing wrong?
This is my app/index.js code:
inbox.onnewfile = () => {
let fileName;
do {
fileName = inbox.nextFile();
if (fileName) {
document.getElementById("coin").image = `/private/data/${fileName}`;
}
} while (fileName);
};
05-14-2022 11:35
05-14-2022 11:35
My watch is a Versa 3
05-14-2022 13:49
05-14-2022 13:49
If it works on sim but not watch, a common cause is because the image is the wrong size. The watch doesn't like resizing images.
05-14-2022 14:06
05-14-2022 14:06
I tried to print it at full size (300x300) and I got the same behavior 😞
05-14-2022 15:42 - edited 05-14-2022 15:43
05-14-2022 15:42 - edited 05-14-2022 15:43
I put a 300x300 image resized to 100x100 directly from resources and I see that image, but when runs this line
document.getElementById("coin").image = `/private/data/${fileName}`;
image become invisible...
maybe how I put the image have a problem...
05-14-2022 15:45
05-14-2022 15:45
Try .href.
05-14-2022 15:51
05-14-2022 15:51
.image and .href has the same behavior
05-14-2022 17:06
05-14-2022 17:06
This is mi companion code:
fetch(coinURL)
.then(response => response.arrayBuffer())
.then(buffer => outbox.enqueue(destFilename, buffer))
.then(fileTransfer => {
console.log(`Enqueued ${fileTransfer.name}`);
});
05-14-2022 20:38 - edited 05-14-2022 20:39
05-14-2022 20:38 - edited 05-14-2022 20:39
Well... using txi conversion it's working, but if I load the same .png directly it load... why I can't pass the file?
fetch(coinURL)
.then(response => response.arrayBuffer())
.then(buffer => Image.from(buffer, "image/png"))
.then(image =>
image.export("image/vnd.fitbit.txi", {
background: "#FFFFFF"
})
)
.then(buffer => outbox.enqueue(destFilename, buffer))
.then(fileTransfer => {
console.log(`Enqueued ${fileTransfer.name}`);
});
05-14-2022 20:42
05-14-2022 20:42
The watch doesn't support PNG. It can only display TXI and (some) JPG.
05-14-2022 20:48
05-14-2022 20:48
But I can load PNG from resources 😕
05-14-2022 20:50
05-14-2022 20:50
PNG included in the source are converted to TXI as part of the build process.
05-15-2022 07:10
05-15-2022 07:10
SDK could make the same thing if I try to set an image from an url response 😞