Identifying endian for HiDPi display problem

I am finding that if an image file is big endian, it does not render correctly in HiDPi. Little endians are fine. Has anyone else encountered this problem and is there a Xojo method to read an image file’s endian property or is there a work around except for memory blocks?
Thanks in advance for your help.

TIFF files?
You can look on first bytes. Little endian ones start with II while the big endian ones start with MM.

Even though Apple now use little endian processors their imaging API still prefers big medians.

Personally I’ve not come across this problem before; is it possible to share the image in question and provide a bit more detail on the problem?

I need to correct my original post. The big-endian images display correctly, the little-endians do not.

Thanks to both of you for your replies.

Christian has the solution, which applies to jpg files also (just checked with Notepad++).

Sam, my photographs were taken with a Sony DSLR-A100 camera and a Canon Power Shot SX150. The Sony saves images in big-endian(Motorola) and the Canon(Intel) in little-endian. I am running Xojo 2016 Pro, Version 4, on Windows 10 via Parallels on an Imac, Retina 5K, 27 inch, Sierra 10.12.2 and have a display containing eight rectangles holding images. All images are read from disk, put in a buffered display and are never physically put on the screen: only via the buffer and paint.

I am converting my program to HiDPi and find that big-endian images display correctly in their rectangles, whereas small-endian images never display correctly and require re-scaling. My understanding is that image sets must contain either landscape or portrait images, not both, therefore I cannot use them. I have no control over the images source: the source can be any variety of camera. Just to muddy the waters further, little-endian images’ original horizontal and vertical resolution determine displayed size somehow, even though the standard paint command is used. That’s another story that I am working on.

I use Phil Harvey’s marvellous ExifTool and Notepad++ to check image files. I have not attached any image files, because if a file is little-endian it displays incorrectly for me.C

Hi James,
Thanks for some more information.

Some background info; I’ve been developing Photography based apps with Xojo since 1998 and while I’ve seen and experienced a wide variety of issues; I have to confess that I’ve not experienced this particular one.

I have a library of sample photos from many many different cameras and many different image file formats, I often download sample images from DPReview.com from new cameras to test my apps with.

Have you created a sample application, whereby you load an image via drag and drop and it displays it scaled in the window?

[code]paint()
Dim scale as double = g.width / p.width
if p.height > g.height then scale = g.height / p.height

Dim newSize as new xojo.core.size( p.width * scale, p.height * scale )
g.drawpicture p, ( g.width - newsize.width ) * 0.5, ( g.height - newsize.height ) * 0.5 ), newsize.width, newsize.height[/code]

I typed this code from memory and it may not be accurate; it’s also incredibly inefficient and I wouldn’t recommend using it in a production application (the image should be sized beforehand and draw directly in the paint event).

You mention Image sets? While I don’t use these, I thought that they were meant for internal application graphics, i.e. icons?

I will admit that almost all of my latest applications don’t actually use the Xojo picture object anymore as they’re macOS only and I use CGImages or CIImages.

Healthy New Year Sam.

I think that I have finally made my app HiDPi functional, but what has been interesting, is that each little-endian file did not scale correctly whilst each big-endian file did. The critical point was getting the image’s vertical and horizontal resolution, which was then used to scale the final image correctly.

“Have you created a sample application, whereby you load an image via drag and drop and it displays it scaled in the window?”

I was originally using Windows explorer for drag and drop and recently switched to OpenDialog, but found that OpenDialog does not close automatically when objects are dragged from it … the Select button must be used. That is another item to be fixed! However, there is no real difference between selecting the file and dragging and dropping it, just convenience. I will be testing the drag and drop today and will let you know the results.

Unless I’m mistaken, I need to use the picture object for cross-platform compatibility, but I am always looking for better ways of doing things.