Skip to content

Commit

Permalink
fix: type errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Julusian committed Aug 9, 2024
1 parent d2273d5 commit 1837e1a
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 22 deletions.
2 changes: 2 additions & 0 deletions satellite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
"build": "rimraf dist && run build:main",
"build:main": "run -T tsc -p tsconfig.build.json",
"build:electron": "electron-builder --publish=never",
"check-types": "run build:main --noEmit",
"watch-types": "run build:main --noEmit --watch",
"lint:raw": "eslint --ext .ts --ext .js --ext .tsx --ext .jsx",
"lint": "run lint:raw ."
},
Expand Down
11 changes: 9 additions & 2 deletions satellite/src/cards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,16 @@ export class CardGenerator {
// return result
const rawImage = Buffer.from(context2d.getImageData(0, 0, canvasWidth, canvasHeight).data)

return await imageRs.ImageTransformer.fromBuffer(rawImage, canvasWidth, canvasHeight, imageRs.PixelFormat.Rgba)
.scale(width, height)
const computedImage = await imageRs.ImageTransformer.fromBuffer(
rawImage,
canvasWidth,
canvasHeight,
imageRs.PixelFormat.Rgba,
)
.scale(width, height, imageRs.ResizeMode.Exact)
.toBuffer(pixelFormat)

return computedImage.buffer
}
}

Expand Down
8 changes: 5 additions & 3 deletions satellite/src/device-types/loupedeck-live-s.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,11 @@ export class LoupedeckLiveSWrapper implements WrappedDevice {
let newbuffer: Buffer = buffer
if (!this.#companionSupportsScaling) {
try {
newbuffer = await imageRs.ImageTransformer.fromBuffer(buffer, 72, 72, imageRs.PixelFormat.Rgb)
.scale(width, height)
.toBuffer(imageRs.PixelFormat.Rgb)
newbuffer = (
await imageRs.ImageTransformer.fromBuffer(buffer, 72, 72, imageRs.PixelFormat.Rgb)
.scale(width, height)
.toBuffer(imageRs.PixelFormat.Rgb)
).buffer
} catch (e) {
console.log(`device(${deviceId}): scale image failed: ${e}`)
return
Expand Down
8 changes: 5 additions & 3 deletions satellite/src/device-types/loupedeck-live.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,11 @@ export class LoupedeckLiveWrapper implements WrappedDevice {
let newbuffer: Buffer = buffer
if (!this.#companionSupportsScaling) {
try {
newbuffer = await imageRs.ImageTransformer.fromBuffer(buffer, 72, 72, imageRs.PixelFormat.Rgb)
.scale(width, height)
.toBuffer(imageRs.PixelFormat.Rgb)
newbuffer = (
await imageRs.ImageTransformer.fromBuffer(buffer, 72, 72, imageRs.PixelFormat.Rgb)
.scale(width, height)
.toBuffer(imageRs.PixelFormat.Rgb)
).buffer
} catch (e) {
console.log(`device(${deviceId}): scale image failed: ${e}`)
return
Expand Down
8 changes: 5 additions & 3 deletions satellite/src/device-types/razer-stream-controller-x.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,11 @@ export class RazerStreamControllerXWrapper implements WrappedDevice {
let newbuffer: Buffer = buffer
if (!this.#companionSupportsScaling) {
try {
newbuffer = await imageRs.ImageTransformer.fromBuffer(buffer, 72, 72, imageRs.PixelFormat.Rgb)
.scale(width, height)
.toBuffer(imageRs.PixelFormat.Rgb)
newbuffer = (
await imageRs.ImageTransformer.fromBuffer(buffer, 72, 72, imageRs.PixelFormat.Rgb)
.scale(width, height)
.toBuffer(imageRs.PixelFormat.Rgb)
).buffer
} catch (e) {
console.log(`device(${deviceId}): scale image failed: ${e}`)
return
Expand Down
21 changes: 10 additions & 11 deletions satellite/src/device-types/streamdeck.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,11 @@ export class StreamDeckWrapper implements WrappedDevice {
if (this.#deck.ICON_SIZE !== 72 && !this.#companionSupportsScaling) {
// scale if necessary
try {
newbuffer = await imageRs.ImageTransformer.fromBuffer(buffer, 72, 72, imageRs.PixelFormat.Rgb)
.scale(this.#deck.ICON_SIZE, this.#deck.ICON_SIZE)
.toBuffer(imageRs.PixelFormat.Rgb)
newbuffer = (
await imageRs.ImageTransformer.fromBuffer(buffer, 72, 72, imageRs.PixelFormat.Rgb)
.scale(this.#deck.ICON_SIZE, this.#deck.ICON_SIZE)
.toBuffer(imageRs.PixelFormat.Rgb)
).buffer
} catch (e) {
console.log(`device(${deviceId}): scale image failed: ${e}`)
return
Expand Down Expand Up @@ -70,14 +72,11 @@ export class StreamDeckWrapper implements WrappedDevice {
// scale if necessary
try {
const inputRes = this.#companionSupportsScaling ? this.#deck.ICON_SIZE : 72
newbuffer = await imageRs.ImageTransformer.fromBuffer(
buffer,
inputRes,
inputRes,
imageRs.PixelFormat.Rgb,
)
.scale(encoderSize.height, encoderSize.height)
.toBuffer(imageRs.PixelFormat.Rgb)
newbuffer = (
await imageRs.ImageTransformer.fromBuffer(buffer, inputRes, inputRes, imageRs.PixelFormat.Rgb)
.scale(encoderSize.height, encoderSize.height)
.toBuffer(imageRs.PixelFormat.Rgb)
).buffer
} catch (e) {
console.log(`device(${deviceId}): scale image failed: ${e}`)
return
Expand Down

0 comments on commit 1837e1a

Please sign in to comment.