https://bugs.documentfoundation.org/show_bug.cgi?id=163748

--- Comment #5 from Heesu Ban <[email protected]> ---
Thanks for the advice.

Changed some code in my Java file like below. but result is the same as before.
No image showed. 
        /*
        PropertyValue[] v = new PropertyValue[2];
        v[0] = new PropertyValue();
        v[0].Name = "InputStream";
        v[0].Value = new ByteArrayToXInputStreamAdapter(imageByteArray);
        v[1] = new PropertyValue();
        v[1].Name = "MimeType";
        v[1].Value = "image/png";
        */
        PropertyValue[] v = new PropertyValue[1];
        v[0] = new PropertyValue();
        v[0].Name = "URL";
        v[0].Value = new
File("BackImage.png").toURI().toURL().toExternalForm();

        XGraphic graphic = xGraphicProvider.queryGraphic(v);

I'm pretty sure XGraphic instance is got normally, 
because graphic is not null and below code saved XGraphic to different png
file. When I opened the other png, it showed image nornally.

        if (graphic == null) {
            System.out.println("Error loading the image");
            return;
        }

        // make sure that PNG file is correct by saving as another file
        PropertyValue[] pv = new PropertyValue[2];
        Path path =
Files.createTempFile(Paths.get(System.getProperty("user.dir")), "temp_",
".png");
        URL url = path.toFile().toURI().toURL();
        String urlString = url.toExternalForm();
        pv[0] = new PropertyValue();
        pv[0].Name = "URL";
        pv[0].Value = urlString;
        pv[1] = new PropertyValue();
        pv[1].Name = "MimeType";
        pv[1].Value = "image/png";
        xGraphicProvider.storeGraphic(graphic, pv);
the very above code saved temp_9399882236891448062.png file, two png files are
not identical but showed same image.

For converting system path to URL. It may be incorrect. but testing is valid
for me in reading and saving image perspective.

If your BASIC sample code is working, I would better change title including
Java.

-- 
You are receiving this mail because:
You are the assignee for the bug.

Reply via email to