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 : Wednesday, March 4, 2009 3:57:04 PM(UTC)

cguanes  
cguanes

Groups: Registered
Posts: 13


I'm using Leadtools V15 with VS 2005 SP1.<br>
I'm reading several images from database and populating a rasterimageviewer control,<br>
I was using rasterimage paging but due the number of images (over the 500, <br>this was causing out of memory on the leadtools control, when reaching 300 image, it was using already 1.9 GB of RAM), <br>I decided to keep the images in a byte array
and have only one image at the time on the <br>rasterimageviewer control (using near 500MB RAM).<br><br>
After this change the rasterimagelist is throwing error when the load event finish.<br><br>

I noticed that after adding the image on the imagelist and initializing (next cycle of loop) the RstImageViewer the <br>
rasterImageLst.Items[previouspage].image is throwing execption when I watch the <br>variable on the QuickWatch.<br><br>

What am I doing wrong? <br>
<br>
while (db2dreader.Read())<br>
{<br>
i++;<br>
RstImgViewer.Image = null;<br>
// create byte array to retrieve the image from the recordset<br>
byteimg[i] = (Byte[])<br>db2dreader.GetDB2Blob(db2dreader.GetOrdinal("evalue")).Value;<br>
mstream = new MemoryStream(byteimg[i]);<br>

// insert the image (memory stream) in the rasterimage control <br>
RstImgViewer.Image = rasterCodecs.Load(mstream);<br>

// add on the thumbnails<br>
tempItem = new RasterImageListItem();<br>
tempItem.Image=RstImgViewer.Image;<br>
tempItem.Text=i.ToString();<br>
rasterImageLst.Items.Add(tempItem);<br>

mstream.Close();<br>
mstream = null;<br>
}<br>


<br>
-----------------------------------------------<br>
Object reference not set to an instance of an object.<br>


at Leadtools.RasterImage.GetImageWidthDpi(Boolean useDpi)<br>
at Leadtools.WinForms.RasterImageList.a(Graphics A_0, RasterImageListItem A_1, Rectangle A_2)<br>
at Leadtools.WinForms.RasterImageList.b(Graphics A_0, RasterImageListItem A_1, Rectangle A_2)<br>
at Leadtools.WinForms.RasterImageList.e(Graphics A_0, RasterImageListItem A_1, Rectangle A_2)<br>
at Leadtools.WinForms.RasterImageList.OnPaint(PaintEventArgs e)<br>
at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer, Boolean disposeEventArgs)<br>
at System.Windows.Forms.Control.WmPaint(Message& m)<br>
at System.Windows.Forms.Control.WndProc(Message& m)<br>
at Leadtools.WinForms.RasterImageList.WndProc(Message& m)<br>
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)<br>
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)<br>
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)<br>
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)<br>
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)<br>
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)<br>
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)<br>
at System.Windows.Forms.Application.Run(Form mainForm)<br>
at WindowsApplication1.Program.Main() in Z:\Visual Csharp\scanmgr\WindowsApplication1\Program.cs:line 19<br><br>
 

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 : Wednesday, March 4, 2009 10:13:37 PM(UTC)
Maen Hasan

Groups: Registered, Tech Support
Posts: 1,326

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

Please create a small working project (not your full application) that shows the problem. Send the project in a new email to support@leadtools.com and mention this forum post in your email.

Please put it in a ZIP or RAR file to ensure our servers accept it.

Thanks,
Maen Badwan
LEADTOOLS Technical Support
 
#3 Posted : Tuesday, March 10, 2009 10:09:59 AM(UTC)

Starkey  
Starkey

Groups: Registered
Posts: 4


Was this issue ever solved. I am getting the same error. I'm using this code snip-it right out of the sample project.

if (_viewer.Image == null)
{
_viewer.Image = e.Image;
}
else
{
_viewer.Image.AddPage(e.Image);
_viewer.Image.Page = _viewer.Image.PageCount;
}

However on the second pass it always throws an object reference error. I checked both objects before calling the addpage() methods and they look valid, but that method fails every time and I get this stack trace.

at Leadtools.RasterImage.GetImageWidthDpi(Boolean useDpi)
at Leadtools.WinForms.RasterImageViewer.b(Object A_0, RasterImageChangedEventArgs A_1)
at Leadtools.RasterImage.AddPage(RasterImage image)
at TestMultipage.MainForm._twain_AcquirePage(Object sender, TwainAcquirePageEventArgs e) in D:\Projects\...\MainForm.cs:line 202


 
#4 Posted : Tuesday, March 10, 2009 10:25:45 AM(UTC)

cguanes  
cguanes

Groups: Registered
Posts: 13


I don't know what version are you using but on V15 the way to add a new page to a rasterimageviwer is using .InsertPage (at least the way that work for me ;-) )

something like...

if (_viewer.Image == null)
{
_viewer.Image = e.Image;
}
else
{
_viewer.Image.InsertPage(Pagecounter++,e.image)
_viewer.Image.Page = Pagecounter
}


and btw my issue on the rasterimagelist was resolved using RstImgViewer.AutoDisposeImages = false; which is true by default....


Carlos

 
#5 Posted : Tuesday, March 10, 2009 11:02:37 AM(UTC)

Starkey  
Starkey

Groups: Registered
Posts: 4


I tried making the changes you suggested but it looks like Insert() just calls addpage().
Here is the new stack trace:
at Leadtools.RasterImage.GetImageWidthDpi(Boolean useDpi)
at Leadtools.WinForms.RasterImageViewer.b(Object A_0, RasterImageChangedEventArgs A_1)
at Leadtools.RasterImage.OnChanged(RasterImageChangedEventArgs e)
at Leadtools.RasterImage.AddPage(RasterImage image)
at Leadtools.RasterImage.InsertPage(Int32 index, RasterImage image)

I am using version 16. I also tried the AutoDisposeImages, but had not luck.

Thanks for trying to help me out, I appreciate it. Hopefully I will hear from a LeadTools support associate and get to the bottom of this.

Thanks,
-Chris
 
#6 Posted : Wednesday, March 11, 2009 6:52:46 AM(UTC)

Starkey  
Starkey

Groups: Registered
Posts: 4


Looks like using this solved the issue.
_viewer.Image = new RasterImage(e.Image);

I was trying to use this based off the sample application (TwainMultiScan)
_viewer.Image = e.Image;

 
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.123 seconds.