Skip to content

Commit

Permalink
fix: load icon image manually, as canvas can't read from asar
Browse files Browse the repository at this point in the history
  • Loading branch information
Julusian committed Jan 20, 2021
1 parent 95d126e commit f047da4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/cards.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
import * as path from 'path'
import { createCanvas, Image, loadImage } from 'canvas'
import { StreamDeck } from 'elgato-stream-deck'
import { promisify } from 'util'
import { readFile } from 'fs'

const readFileP = promisify(readFile)

export class CardGenerator {
private iconImage: Image | undefined

async loadIcon(): Promise<Image> {
if (!this.iconImage) {
this.iconImage = await loadImage(path.join(__dirname, '../assets/icon.png'))
const rawData = await readFileP(path.join(__dirname, '../assets/icon.png'))
this.iconImage = await loadImage(rawData)
}

return this.iconImage
Expand Down
2 changes: 1 addition & 1 deletion src/devices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ export class DeviceManager {
dev.deck.clearAllKeys()

this.cardGenerator
.generateBasicCard(dev.deck, 'aaa', this.statusString)
.generateBasicCard(dev.deck, this.client.host, this.statusString)
.then((buffer) => {
if (outputId === dev.queueOutputId) {
// still valid
Expand Down

0 comments on commit f047da4

Please sign in to comment.