Results 1 to 11 of 11

Thread: What's the best way to load 16bit-grayscale and 48bit-RGB PNG and TIF images?

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2008
    Posts
    1,001

    What's the best way to load 16bit-grayscale and 48bit-RGB PNG and TIF images?

    PNG and TIF images of any kind are not supported in VB6 or even in the normal Windows GDI functions, but they are supported in the GDI+ functions. But GDI+ has a problem still. It can't actually load high-bitdepth images (such as 16bit gray and 48bit RGB). The MSDN documentation makes this quite clear. So I need a better solution. If anybody can recommend a better image loading framework than GDI+ for VB6, please let me know. Many scientific images are in 16bit grayscale format (either PNG or TIF, or a proprietary format made by the image capturing device but can be converted to PNG or TIF with software made by the device manufacturer).
    Thanks in advance.

  2. #2
    Addicted Member
    Join Date
    Jan 2010
    Posts
    181

    Re: What's the best way to load 16bit-grayscale and 48bit-RGB PNG and TIF images?

    maybe you should try lavolpealphaimage control (ocx) which can load almost known image type

  3. #3
    Frenzied Member
    Join Date
    Dec 2014
    Posts
    1,051

    Re: What's the best way to load 16bit-grayscale and 48bit-RGB PNG and TIF images?

    did u look if wic (Windows Imaging Component) can load it? https://docs.microsoft.com/en-us/win...-pixel-formats
    what about Cairo?

  4. #4
    PowerPoster
    Join Date
    Jun 2013
    Posts
    4,923

    Re: What's the best way to load 16bit-grayscale and 48bit-RGB PNG and TIF images?

    Quote Originally Posted by baka View Post
    ...what about Cairo?
    RC5 does not support any Tiff-loading...

    Though (FWIW) it can load 16Bit-greyscale and 48Bit-color-PNGs -
    but the loading-process converts both formats into 24bpp+8 = 32bpp "normal true-color-surfaces with Alpha",
    before showing them.

    So, "one can see them" - but Users with highend (16bit per color-channel, instead of 8) -monitors
    will not benefit from the original 16bpp-highres per color-channel, contained in the original image-blob.

    If one wants to keep that information (after loading), then alternative libraries (as e.g. libPNG or FreeImage) should be used.

    Olaf

  5. #5
    PowerPoster
    Join Date
    Feb 2006
    Posts
    21,058

    Re: What's the best way to load 16bit-grayscale and 48bit-RGB PNG and TIF images?

    I believe there is WIC support for these image types, but I haven't worked with any typelibs supporting WIC yet myself. That might preserve the bit depth, I don't know. But displaying such images probably always requires some compromise because of video adapter and driver limitations.

  6. #6

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2008
    Posts
    1,001

    Re: What's the best way to load 16bit-grayscale and 48bit-RGB PNG and TIF images?

    Quote Originally Posted by Schmidt View Post
    RC5 does not support any Tiff-loading...

    Though (FWIW) it can load 16Bit-greyscale and 48Bit-color-PNGs -
    but the loading-process converts both formats into 24bpp+8 = 32bpp "normal true-color-surfaces with Alpha",
    before showing them.

    So, "one can see them" - but Users with highend (16bit per color-channel, instead of 8) -monitors
    will not benefit from the original 16bpp-highres per color-channel, contained in the original image-blob.

    If one wants to keep that information (after loading), then alternative libraries (as e.g. libPNG or FreeImage) should be used.

    Olaf
    I'm quite surprised that neither the older GDI nor the newer GDI+ doesn't work on 16bpp PNGs and TIFFs and simply decompress them and hand them back to the program as an array of 16bit Integers, and say "here you go, I've just decompressed your high bitdepth PNG and here's the raw array of 16bit values". I mean MS is a big compnay, with many knowlegable software engineers. I do believe it is within their capability to make a PNG loader API DLL a standard part of their OS, in a way that would allow programmers to read and write all kinds of PNG files that are part of the official PNG specification (and same thing with TIFFs). Basically an MS-created full-capability library for PNG (and TIFF) in the same way that the non-MS full-capability library libPNG (and libTIFF) is. Microsoft has made GDI, and then after years an improved version called GDI+, and in those years they have failed to implement a full-capability PNG and TIFF library? WOW! Just WOW!

    And I can't use libPNG or libTIFF in any VB6 program. As with most DLLs who's name starts with "lib" and is based on a specific file format (such as PNG or TIFF), the libPNG and libTIFF DLLs sadly use CDECL calling convention (not STDCALL calling convention), and that means that they can't be used directly in VB6 (though some hacky techniques via the Windows API to call CDECL functions is still possible).

  7. #7

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2008
    Posts
    1,001

    Re: What's the best way to load 16bit-grayscale and 48bit-RGB PNG and TIF images?

    Quote Originally Posted by dilettante View Post
    I believe there is WIC support for these image types, but I haven't worked with any typelibs supporting WIC yet myself. That might preserve the bit depth, I don't know. But displaying such images probably always requires some compromise because of video adapter and driver limitations.
    I may be mistaken, but I think WIC is simply a wrapper for GDI+.

  8. #8
    Frenzied Member
    Join Date
    Dec 2014
    Posts
    1,051

    Re: What's the best way to load 16bit-grayscale and 48bit-RGB PNG and TIF images?

    you are confusing WIC with WIA.
    I posted a link to microsoft about WIC, if you bothered to check it out you would know what WIC is.
    if you are interested in WIC, The trick created a typelib to use WIC and Direct2D (but you can use WIC together with GDI as well)

  9. #9
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    2,198

    Re: What's the best way to load 16bit-grayscale and 48bit-RGB PNG and TIF images?

    Quote Originally Posted by Ben321 View Post
    And I can't use libPNG or libTIFF in any VB6 program. As with most DLLs who's name starts with "lib" and is based on a specific file format (such as PNG or TIFF), the libPNG and libTIFF DLLs sadly use CDECL calling convention (not STDCALL calling convention), and that means that they can't be used directly in VB6 (though some hacky techniques via the Windows API to call CDECL functions is still possible).
    Compile it yourself?
    libpng: https://fossies.org/linux/libpng/pro.../libpng.vcproj
    One System to rule them all, One IDE to find them,
    One Code to bring them all, and to the Framework bind them,
    in the Land of Redmond, where the Windows lie
    ---------------------------------------------------------------------------------
    People call me crazy because i'm jumping out of perfectly fine airplanes.
    ---------------------------------------------------------------------------------
    For health reasons i try to avoid reading unformatted Code

  10. #10
    Frenzied Member wqweto's Avatar
    Join Date
    May 2011
    Posts
    2,034

    Re: What's the best way to load 16bit-grayscale and 48bit-RGB PNG and TIF images?

    Quote Originally Posted by Zvoni View Post
    Nice! So there is DLL VB|Win32 configuration w/ stdcall calling convention from the project maintainers already?

    cheers,
    </wqw>

  11. #11
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    2,198

    Re: What's the best way to load 16bit-grayscale and 48bit-RGB PNG and TIF images?

    Quote Originally Posted by wqweto View Post
    Nice! So there is DLL VB|Win32 configuration w/ stdcall calling convention from the project maintainers already?

    cheers,
    </wqw>
    Looks like it
    Line 117: The PNGAPI PreprocessorDefinition
    Last edited by Zvoni; Jun 4th, 2020 at 01:41 AM.
    One System to rule them all, One IDE to find them,
    One Code to bring them all, and to the Framework bind them,
    in the Land of Redmond, where the Windows lie
    ---------------------------------------------------------------------------------
    People call me crazy because i'm jumping out of perfectly fine airplanes.
    ---------------------------------------------------------------------------------
    For health reasons i try to avoid reading unformatted Code

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width