Welcome Guest! To enable all features, please Login or Register.

Notification

Icon
Error

Options
View
Last Go to last post Unread Go to first unread post
#1 Posted : Thursday, April 2, 2009 9:50:06 PM(UTC)

Karthik  
Karthik

Groups: Registered
Posts: 6


Hi,

When I use codecs.load() i am getting "Invalid File Format" error message.

 

I am using LeadTools version 16. Reference have been given to the following dlls.

Leadtools.dll,Leadtools.winforms.dll,Leadtools.codecs.dll,Leadtools.codecs.jpg.dll. And the same dlls have been copied the directory where my exe resides.

Please find below the code.

 

RasterCodecs.Startup();   

RasterCodecs codecs = new RasterCodecs();

 

Tried the following methods

1 . RasterImage tempImg = codecs.Load(@"C:\\Program Files\\Readiris Pro 8\\autoform.jpg", 8, Leadtools.Codecs.CodecsLoadByteOrder.BgrOrGray, 1, -1);

2. RasterImage tempImg = codecs.Load(@"C:\\Program Files\\Readiris Pro 8\\autoform.jpg");

 

3. System.Drawing.Image image = System.Drawing.Image.FromFile(@"C:\\Program Files\\Readiris Pro 8\\autoform.jpg");

   MemoryStream stream = new MemoryStream();

   image.Save(stream, System.Drawing.Imaging.ImageFormat.Jpeg);

   RasterImage tempImg = codecs.Load(stream);

 

   RasterCodecs.Shutdown();

 

I am getting the same error in all the above three methods.

 

Please help me in fixing this issue.

 

 

 

Try the latest version of LEADTOOLS for free for 60 days by downloading the evaluation: https://www.leadtools.com/downloads

Wanna join the discussion? Login to your LEADTOOLS Support accountor Register a new forum account.

#2 Posted : Sunday, April 5, 2009 2:38:36 AM(UTC)

Basel  
Guest

Groups: Guests
Posts: 3,022

Was thanked: 2 time(s) in 2 post(s)

I'm afraid you are not including the correct reference for loading a JPEG image. We don't have a DLL named leadtools.codecs.jpg.dll. Either you misspelled it or you are using a non-LEAD DLL.  

To load a JPEG image you need to add leadtools.codecs.CMP.DLL to your project references.

 
#3 Posted : Sunday, April 5, 2009 9:05:38 PM(UTC)

Karthik  
Karthik

Groups: Registered
Posts: 6


Thanks for your response. I have solved this issue by giving the following statement before loading the loading the image into codecs.

codecs.Options.Load.Format = RasterImageFormat.Jpeg;

RasterImage tempImg = codecs.Load(@"C:\\Program Files\\Readiris Pro 8\\alphabets.Jpg");

what should be format type for the following code

 

System.Drawing.Image image = System.Drawing.Image.FromFile(@"C:\\Program Files\\Readiris Pro 8\\alphabets.tif");

MemoryStream stream = new MemoryStream();

image.Save(stream, System.Drawing.Imaging.ImageFormat.Tiff);

RasterCodecs.Startup();

RasterCodecs codecs = new RasterCodecs();

RasterImage tempImg = codecs.Load(stream);

I tried with Jpeg and Tif and several other options. It's giving "Invalid File Format" in Codecs.load(stream) statement.

Please help me in fixing the same.

 

 

 
#4 Posted : Monday, April 6, 2009 2:29:06 AM(UTC)

Basel  
Guest

Groups: Guests
Posts: 3,022

Was thanked: 2 time(s) in 2 post(s)

You do NOT need to set codecs.Options.Load.Format before loading. You only need to include the correct DLLs

About the new issue, it is most likely caused by the stream pointer not being positioned at the stream start. Please try to seek to the stream beginning before calling our Load() function like this:
stream.Seek(0, SeekOrigin.Begin)
 
#5 Posted : Monday, April 6, 2009 3:01:19 AM(UTC)

Karthik  
Karthik

Groups: Registered
Posts: 6


 It worked.Thank you so much.
 
#6 Posted : Thursday, November 19, 2009 1:39:48 PM(UTC)
Steven_Gaines

Groups: Registered
Posts: 2


Basel,

I followed your instructions and added a reference to Leadtools.Codecs.Cmp.dll in my C# project and I still get the "Invalid File Format" message when attempting to load a jpg file.

Here's my code:
RasterCodecs.Startup();
RasterCodecs codecs = new RasterCodecs();

codecs.ThrowExceptionsOnInvalidImages = true;

try
{
codecs.Options.Load.Format = RasterImageFormat.Jpeg;
RasterImage image = codecs.Load(@"D:\Development\Applications\2010ReservesImaging\2010ReservesImaging\2010ReservesImaging\bin\Debug\Images\" + "60a15f91-bcb5-44f3-90db-29dd3f9be771.jpg");
}

What do I need to do different to get this error to resolve?

Your help is much appreciated!!

Steven
 
#7 Posted : Saturday, November 21, 2009 11:37:21 PM(UTC)
Maen Hasan

Groups: Registered, Tech Support
Posts: 1,326

Was thanked: 1 time(s) in 1 post(s)

Steven,

Can you please send me the JPEG image that you are trying to load?

Please put the JPEG image in a ZIP or RAR file and either post it here or send it to support@leadtools.com and mention this forum post.

Thanks,
Maen Badwan
LEADTOOLS Technical Support
 
#8 Posted : Sunday, January 31, 2010 1:34:58 PM(UTC)
Steven_Gaines

Groups: Registered
Posts: 2


Maen,

Sorry it has taken me so long to respond. I didn't know you had responded to my post. Should I expect notification by e-mail when a post I've made has been answered or responded to?

Either way, I don't have that problem anymore as we've switched from using .jpg/.jpeg files to using .png files. I then added a reference to Leadtools.Codecs.Png in my .net project and everything works fine.

Thanks for your reply,

Steven
 
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF.NET | YAF.NET © 2003-2024, Yet Another Forum.NET
This page was generated in 0.107 seconds.