July 29, 2021, 11:01:10

Author Topic: Read and write in TIFF format  (Read 547 times)

Offline Ryszard

  • Jr. Member
  • **
  • Posts: 47
Read and write in TIFF format
« on: March 31, 2021, 08:08:54 »
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.
« Last Edit: March 31, 2021, 14:01:53 by Ryszard »

Offline Scaremonger

  • Full Member
  • ***
  • Posts: 230
    • ITSpeedway - Ramblings of a geek!
Re: Read and write in TIFF format
« Reply #1 on: March 31, 2021, 16:43:51 »
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...

Offline Henri

  • Sr. Member
  • ****
  • Posts: 340
Re: Read and write in TIFF format
« Reply #2 on: March 31, 2021, 17:48:12 »
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
« Last Edit: March 31, 2021, 18:27:53 by Henri »
- Got 01100011 problems, but the bit ain't 00000001

Offline Ryszard

  • Jr. Member
  • **
  • Posts: 47
Re: Read and write in TIFF format
« Reply #3 on: March 31, 2021, 19:20:55 »
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.

Offline Henri

  • Sr. Member
  • ****
  • Posts: 340
Re: Read and write in TIFF format
« Reply #4 on: March 31, 2021, 20:00:38 »
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

Offline Ryszard

  • Jr. Member
  • **
  • Posts: 47
Re: Read and write in TIFF format
« Reply #5 on: April 01, 2021, 09:50:21 »
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?

Offline Henri

  • Sr. Member
  • ****
  • Posts: 340
Re: Read and write in TIFF format
« Reply #6 on: April 01, 2021, 12:03:37 »
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 
« Last Edit: April 01, 2021, 12:09:07 by Henri »
- Got 01100011 problems, but the bit ain't 00000001

Offline Ryszard

  • Jr. Member
  • **
  • Posts: 47
Re: Read and write in TIFF format
« Reply #7 on: April 01, 2021, 19:41:11 »
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.

Offline Henri

  • Sr. Member
  • ****
  • Posts: 340
Re: Read and write in TIFF format
« Reply #8 on: April 02, 2021, 09:40:18 »
If you have TFreeImage object you can use:
Code: BlitzMax
  1. local success:int = img.Save("C:\test\mytiff.tif", FIF_TIFF, TIFF_NONE)   ' TIFF_NONE is lossless
  2. if success then Print "Saved succesfully"; else Print "Saving failed"

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

Offline Ryszard

  • Jr. Member
  • **
  • Posts: 47
Re: Read and write in TIFF format
« Reply #9 on: April 05, 2021, 22:10:42 »
I have Local pixmap:TPixmap=(LoadPixmap(filename))

Offline Derron

  • Hero Member
  • *****
  • Posts: 3614
Re: Read and write in TIFF format
« Reply #10 on: April 06, 2021, 08:13:35 »
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

Offline Ryszard

  • Jr. Member
  • **
  • Posts: 47
Re: Read and write in TIFF format
« Reply #11 on: April 06, 2021, 12:22:08 »
SuperStrict

Framework BaH.FreeImage
Import brl.glmax2d

Offline Derron

  • Hero Member
  • *****
  • Posts: 3614
Re: Read and write in TIFF format
« Reply #12 on: April 06, 2021, 12:26:39 »
so you use freeimage - which has own loaders too.

bye
Ron

Offline Ryszard

  • Jr. Member
  • **
  • Posts: 47
Re: Read and write in TIFF format
« Reply #13 on: April 06, 2021, 13:31:26 »
How do I save a pixmap in tiff format?

Offline Midimaster

  • Sr. Member
  • ****
  • Posts: 329
    • Midimaster Music Education Software
Re: Read and write in TIFF format
« Reply #14 on: April 06, 2021, 15:11:20 »
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.
See my current project on PlayStore: 20Tracks-Audio-Player https://play.google.com/store/apps/details?id=midimaster.twentytrackd

 

SimplePortal 2.3.6 © 2008-2014, SimplePortal