Recent

Author Topic: loading tiff image error  (Read 770 times)

Packs

  • Sr. Member
  • ****
  • Posts: 479
loading tiff image error
« on: February 14, 2025, 11:31:10 am »
I want to load tiff image on timage component


1st method Design time it is working properly
2nd method : runtime try to load img_front.Picture.LoadFromFile('xyz.tif'); getting error exception class 'FPImageException'  wrong image format

3rd method :
Code: Pascal  [Select][+][-]
  1.  
  2.  TIFF: TTiffImage;    
  3. TIFF := TTiffImage.Create;  
  4. TIFF.LoadFromFile('xyz.tif);  
  5. img_front.Picture.Bitmap.Assign(TIFF);    
  6.  
  7. compression CCITT Group 4 fax encoding not supported yet at position  
  8.  

Please guide correct method to load tif image

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12110
  • FPC developer.
Re: loading tiff image error
« Reply #1 on: February 14, 2025, 12:19:20 pm »

Packs

  • Sr. Member
  • ****
  • Posts: 479
Re: loading tiff image error
« Reply #2 on: February 14, 2025, 01:28:22 pm »
Dear sir.

any solution or option

domasz

  • Hero Member
  • *****
  • Posts: 566
Re: loading tiff image error
« Reply #3 on: February 14, 2025, 06:57:39 pm »
Okay, so TIFF stands for Thousands of Incompatible File Formats. It's basically a container inside which you can put lots and lots of different file formats, even JPEGs.
There doesn't exist a single program that supports all possible TIFF formats. Current implementation in Lazarus does support just a few.
Solutions:
1) use a different TIFF format, for example LZW
2) call a program (for example imagemagick) in background to convert from TIFF to something else, for example BMP
3) under Windows you might try GDI+. It does supports some TIFF formats

Packs

  • Sr. Member
  • ****
  • Posts: 479
Re: loading tiff image error
« Reply #4 on: February 15, 2025, 04:37:32 am »
How it is getting loaded at design time

domasz

  • Hero Member
  • *****
  • Posts: 566
Re: loading tiff image error
« Reply #5 on: February 15, 2025, 11:01:37 am »
Can you post here you TIFF file?

cdbc

  • Hero Member
  • *****
  • Posts: 1964
    • http://www.cdbc.dk
Re: loading tiff image error
« Reply #6 on: February 15, 2025, 11:06:47 am »
Hi
Could it be a "library location" thingy, i.e.: At designtime the lib is known to the IDE and at runtime, the app can't /see/ the lib?!?
Regards Benny
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE5 -> FPC 3.2.2 -> Lazarus 3.6 up until Jan 2024 from then on it's both above &: KDE5/QT5 -> FPC 3.3.1 -> Lazarus 4.99

Packs

  • Sr. Member
  • ****
  • Posts: 479
Re: loading tiff image error
« Reply #7 on: February 15, 2025, 12:17:12 pm »
sharing you zip file which contain TIF image file .

DragoRosso

  • Guest
Re: loading tiff image error
« Reply #8 on: February 15, 2025, 01:05:01 pm »
I can use this tiff file everywhere in Windows, also Delphi native support it.

You can use WICImage class of Windows to load this image and simply transform it like in example:

Code: Pascal  [Select][+][-]
  1. procedure TForm1.Button1Click(Sender: TObject);
  2. var tempfilename: string;
  3.     tempimmagine: TWICImage;
  4.     tempbitmap: TBitmap;
  5. begin
  6.   tempbitmap := nil;
  7.     begin
  8.       try
  9.         tempfilename := 'BTT358010816040220250140001200983558.tif';
  10.         tempbitmap := TBitmap.Create;
  11.         tempimmagine := TWICimage.Create;
  12.         tempimmagine.LoadFromFile(tempfilename);
  13.         tempbitmap.Assign(tempimmagine);
  14.         Image1.Picture.Assign(tempbitmap);
  15.       except
  16.         ;
  17.       end;
  18.       if Assigned(tempbitmap) then
  19.         tempbitmap.Free;
  20.       if Assigned(tempimmagine) then
  21.         tempimmagine.Free;
  22.     end;
  23. end;

In Delphi there is a standard implementation (Windows unity) TWICImage that incapsulate the Windows object, but I was not able to find one equivalente in Lazarus / FPC.

There is one somewhere ?

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12110
  • FPC developer.
Re: loading tiff image error
« Reply #9 on: February 15, 2025, 01:37:54 pm »
Maybe one of the WIA or DirectShow packages for older Delphis have something that you can adapt to lazarus. Like DSPack.

domasz

  • Hero Member
  • *****
  • Posts: 566
Re: loading tiff image error
« Reply #10 on: February 15, 2025, 01:39:59 pm »
sharing you zip file which contain TIF image file .
I can't load your file to TImage in Lazarus in either design mode or run time. Maybe Windows rendered a preview for you when you where selecting the image but Lazarus just doesn't support this TIFF format out of the box.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12110
  • FPC developer.
Re: loading tiff image error
« Reply #11 on: February 15, 2025, 02:02:39 pm »
It is a type that is typically used by fax machines, something that went somewhat out of favour, which is probably why nobody bothered yet.

IIRC Mattias once tried, but I don't know what became of it.


DragoRosso

  • Guest
Re: loading tiff image error
« Reply #12 on: February 15, 2025, 04:17:45 pm »
From this Topic ( https://forum.lazarus.freepascal.org/index.php?topic=47014.15 ) I extract the code and it's working for this image. May be with a little works, who is interested can make a standard addon x FPC and Lazarus.

Packs

  • Sr. Member
  • ****
  • Posts: 479
Re: loading tiff image error
« Reply #13 on: February 15, 2025, 08:05:45 pm »
Is there any alternative options.

Like any other language will convert to bmp in the background and I will show in Lazarus application

Tomxe

  • New Member
  • *
  • Posts: 37
Re: loading tiff image error
« Reply #14 on: February 16, 2025, 04:07:51 am »

 

TinyPortal © 2005-2018