April 26, 2024, 03:44:17 AM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


Playing around with JPG files

Started by Egil, May 24, 2016, 07:57:46 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Egil

Last year I struggled a lot doing routines for loading and finding dimensions for JPG images, but never was quite satisfied.
I know next to nothing about how the image format is built up, so this morning I decided to try to understand the format description. But when I saw the TAG-names used, I suddenly remeberred some code Graham posted several years ago: http://www.ionicwind.com/forums/index.php?topic=4038.msg31741#msg31741

His code was modified to fit into the map viewing code I have been working on every now and then, and found Graham's way of doing it was much faster than the methods I tried before.

When loading one of the images used for testing, the program came up with a messagebox saying: "JFIF APP0 not found". When the program then was stopped, CB editor came up with an error saying: "IF without ENDIF in line 185".
I put an ENDIF into line 190, and the CB error message dissapeared when trying again with the same image. For all the other images tested, no warnings were given, ENDIF in line 190 or not.

I have tried several methods for determining jpg width and height. Graham's method is the only one that accepts images larger than around 2MB. The largest image file I tested was a little more than 30MB, and took less than two seconds to load from a USB stick, scale down and print on my screen. That is fast!

So now my next goal is to find an available database containing names of cities all over the world and their coordinates. I have found one particular CSV file containing data for around 1700 cities. If I get permission to use that one, and make provision for adding new additions to the list, that will be a good start. But I'm always open for suggestions.

The maps I have used for my experiments are downloaded from: http://www.shadedrelief.com/natural3/pages/textures.html
Put them in the same directory as my program. A default map is included in the zip file, but downloading larger images are recomended.

Finally, thanks to Graham I still don't know the JPG format secrets. I'll leave it that way. :D


Have fun!

Egil


Support Amateur Radio  -  Have a ham  for dinner!