Read and write in TIFF format

Started by Ryszard, March 31, 2021, 08:08:54

Previous topic - Next topic

Ryszard

Good day!

I would like to read images saved in TIFF format. After processing I would like to save the pixmaps also as TIFFs. I tried the Freeimage module to import into BlitzMax but failed.

Scaremonger

Hi,
I didn't know anyone still used TIFF. I haven't used it for a long time after converting all my documents many years back.

I don't think there is any native support for TIFF in BlitzMax, but there is a library over in GitLab that you may be able to create an interface with.

Si...

Henri

#2
I too have encountered the dreaded 'failed' -error (:-)), but I assure you it is possible to use Freeimage to convert from <some format> to TIF as I just tried it out and it worked.

-Henri
- Got 01100011 problems, but the bit ain't 00000001

Ryszard

I assure you that TIFF is used quite often. It is lossless. It scans and thresholds technical drawings 256 shades of grayscale-->1-bit black and white. If there are many that require local thresholds it scans in grayscale and saves to TIFF. It's faster than PNG. And this can be seen in the scanner software. Then a batch conversion to PNG. BlitzMax reads it. And processing with Blitzmax. But if the drawings are OK then only a few-something needs local thresholding. Midimaster has written a great program for this. But it needs a TIFF-PNG conversion. So far Irfanview does it both ways. Tiff --> PNG --> pixmap. And then in the other direction. As if Blitz reads TIFF there would be 2 conversions dropped. I see that I am not the only one who has problems with it.

Henri

Maybe start by telling what 'fails'  (as I mentioned it worked for me) ?

You can't get freeimage.mod to compile as it spews errors or don't know how to use it to do what you want ?

Where did you download freeimage ?

Are you using Blitzmax NG downloaded from the blitzmax.org or plain old 1.5 Blitzmax ?

-Henri
- Got 01100011 problems, but the bit ain't 00000001

Ryszard

Blitzmax NG. All from the official site. I installed the modules. It reported a couple of errors in the middle of the display. I didn't have time to notice what it was scrolling so fast. I built the documentation. I don't see anything in the Help. How do I check to see if this is OK?

Henri

#6
Check that you have:

  1. Folder named <Blitzmax>\mod\bah.mod\freeimage.mod               -> This means that folder structure is correct
  2. Inside freeimage.mod folder there are files ending with .a and .i     -> This means that mod was compiled

Open test_01.bmx from freeimage.mod\tests folder with MaxIDE and try to build and run. If there are any errors in the console (the output tab) then post them here.

-Henri 
- Got 01100011 problems, but the bit ain't 00000001

Ryszard

At first, I copied the bah.mod folder to the modules folder. It didn't work. I asked a question. You answered. There were no files with endings .a and .i. I deleted, left the freeimage.mod folder in bah.mod. Rebulding all modules. There are files in the freeimage.mod folder with the .a and .i endings. I ran the examples. They load the tif. Still as a bonus ;) I got rotate and convert functions. Now I'm looking at how to save the pixmap in tif format. Later I will look what other modules are in bah.mod which I have not installed but may be useful. Thank you.

Henri

If you have TFreeImage object you can use:
Code (blitzmax) Select

local success:int = img.Save("C:\test\mytiff.tif", FIF_TIFF, TIFF_NONE)   ' TIFF_NONE is lossless
if success then Print "Saved succesfully"; else Print "Saving failed"


-Henri
- Got 01100011 problems, but the bit ain't 00000001

Ryszard

I have Local pixmap:TPixmap=(LoadPixmap(filename))

Derron

LoadPixmap can only load formats supported by loaded modules. by default it loads stuff from brl.mod - which contains
bmploader.mod
jpgloader.mod
pngloader.mod
stbimageloader.mod
tgaloader.mod

stbimageloader supports "formats include, BMP, PSD, TGA, GIF, HDR, PIC and PNM"
tgaloader loads "tgahdr" via stb too.

So ... hmm dunno why you can load "tiff"  - maybe supported by stb too.


bye
Ron

Ryszard

SuperStrict

Framework BaH.FreeImage
Import brl.glmax2d

Derron

so you use freeimage - which has own loaders too.

bye
Ron

Ryszard

How do I save a pixmap in tiff format?

Midimaster

If you installed the module correct you should find on the right side of your BlitzMax-IDE new commands and functions related to the new module.

Or if you alreay know one command, write it in the IDE and then set the cursor into the word and press twice F1. This will open the help with all related commands for this module.
...back from North Pole.