PNG picture - Console/Desktop - Same code, different result

  1. 2 weeks ago

    Pietro B

    Nov 27 Pre-Release Testers, Xojo Pro Europe (Swiss, Chiasso)

    Using this code

    dim p as Picture
    p = picture.Open(GetFolderItem("c:\temp\aaa.png",3))

    Into desktop app, p has horizontal and vertical resolution as 96; type ImmutableBitmap = 3
    Into console app, p has horizontal and vertical resolution as 72; type MutableBitmap = 2

    When p is saved with

    p.Save(f, Picture.SaveAsPNG, -1)

    and than f is passed to zbarimg.exe for barcode recognition, into desktop app barcode is recognized, but not into console app.

    So my question is: "Why the same code with the same source image file, produces different picture objects?"

  2. Dave S

    Nov 27 San Diego, California USA

    I think Greg or someone addressed this issue else where on this forum... and if I recall it has something to do with the fact the a different graphics engine is used in each case. I don't recall if a workaround was offered or not...

    And based on the fact you mentioned 96dpi... I am assuming this is WIndows?

  3. Greg O

    Nov 27 Xojo Inc
    Edited 2 weeks ago

    @Dave S and if I recall it has something to do with the fact the a different graphics engine is used in each case.

    Right.

    The problem is probably the horizontal and vertical resolutions. Most apps assume a resolution of 96ppi on Windows and 72ppi on macOS. On Windows the underlying OS calls have a hard time when the ppl isn’t what it expects to find.

    You may be able to fix this in the console app by setting the HorizontalResilution and VerticalResolution to 96 before calling Save.

or Sign Up to reply!