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

"Invalid argument" error while trying to display the image #34

Open
wygodny opened this issue Nov 4, 2020 · 0 comments
Open

"Invalid argument" error while trying to display the image #34

wygodny opened this issue Nov 4, 2020 · 0 comments

Comments

@wygodny
Copy link

wygodny commented Nov 4, 2020

I cannot force the vn-image component to display the selected image from the disk. Both when I use the src parameter and the buffer I get an error message:

Error: Invalid argument
    at s.loadFromData (D:\Projekty\img-butcher\dist\main.js:1:49832)
    at buffer (D:\Projekty\img-butcher\dist\main.js:1:504356)
    at a.patchProp (D:\Projekty\img-butcher\dist\main.js:1:505049)
    at t.default (D:\Projekty\img-butcher\dist\main.js:1:516165)
    at T (D:\Projekty\img-butcher\dist\main.js:1:289542)
    at C (D:\Projekty\img-butcher\dist\main.js:1:289176)
    at b (D:\Projekty\img-butcher\dist\main.js:1:288774)
    at U (D:\Projekty\img-butcher\dist\main.js:1:296380)
    at L (D:\Projekty\img-butcher\dist\main.js:1:295667)
    at W (D:\Projekty\img-butcher\dist\main.js:1:291591)

My code:

<template>
  <vn-view id="main-view">
    <vn-text id="text">Select files:</vn-text>
    <vn-button @clicked="handleClicked">
      Load ...
    </vn-button>
    <vn-image
      v-for="file in selectedFiles"
      :key="`img-${file}`"
      :buffer="file"
    />
  </vn-view>
</template>

<script>
import { QPixmap } from '@nodegui/nodegui';
import { ref } from '@nodegui/vue-nodegui';
import path from 'path';
import { log } from 'util';
import selectImagesDialog from '../../utils/selectImagesDialog';

function mapPathToPixmap(imgPath) {
  const pixmap = new QPixmap();
  pixmap.load(path.normalize(imgPath));
  return pixmap;
}

export default {
  setup() {
    const selectedFiles = ref([]);
    return {
      selectedFiles,
      handleClicked: () => {
        const paths = selectImagesDialog();
        const pixmaps = paths.map(mapPathToPixmap);
        selectedFiles.value = pixmaps;
      }
    };
  }
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant