Welcome Guest! You need to login or register to make posts.

Notification

Icon
Error

Options
Go to last post Go to first unread
bdavi19  
#1 Posted : Thursday, August 24, 2006 12:12:13 AM(UTC)
bdavi19

Rank: Member

Groups: Member
Joined: 3/23/2006(UTC)
Posts: 14

I am getting a strange error. I'm using the ThumbnailListViewer in a Windows Form application. When I open a form, it loads all of the images into the ThumbnailListViewer. Normally, this works fine. However, if I open the form then close it two or three times in a row I get an InvalidOperationException in the AddImage method in the thumbnailimagelist object. The code is as follows:

Code:
		public override int AddImage(Aurigma.GraphicsMill.Bitmap image)
		{
            try
			{
				lock (this)
				{
					Aurigma.GraphicsMill.Bitmap imgResult = null;
					CreateListImage(_imageList.ImageSize, _bkColor, _listItemBackgroundImage, _listItemForegroundImage, image, out imgResult);
					_imageList.Images.Add(imgResult.ToGdiplusBitmapDirectly());
					imgResult.Dispose();
				}
			}
			catch(Exception)
			{
				return -1;
			}
			return _imageList.Images.Count - 1;
		}



The Highlighted line is the one that throws the error. Do you know what could be causing this? Thanks.

ETA:
This is the error and the stacktrace:

Code:
"Image cannot be added to the ImageList"
   at System.Windows.Forms.ImageList.AddToHandle(Original original, Bitmap bitmap)
   at System.Windows.Forms.ImageList.ImageCollection.Add(Original original, ImageInfo imageInfo)
   at System.Windows.Forms.ImageList.ImageCollection.Add(Image value)
   at Aurigma.GraphicsMill.WinControls.ThumbnailImageList.AddImage(Bitmap image)
   at Aurigma.GraphicsMill.WinControls.ThumbnailListItem.EvalMethod2()
   at Aurigma.GraphicsMill.WinControls.ThumbnailListItem.EvaluateMethod(Int32 methodIndex)
   at Aurigma.GraphicsMill.WinControls.Queue.EvaluateQueue()
   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()

Edited by user Wednesday, December 19, 2007 3:01:20 PM(UTC)  | Reason: Not specified

Dmitry  
#2 Posted : Thursday, August 24, 2006 5:15:20 PM(UTC)
Dmitry

Rank: Advanced Member

Groups: Member, Administration, Moderator
Joined: 8/3/2003(UTC)
Posts: 1,070

Thanks: 1 times
Was thanked: 12 time(s) in 12 post(s)
Hello,

Try to use Bitmap.ToGdiplusBitmap instead of Bitmap.ToGdiplusBitmapDirectly. It should help.
Sincerely yours,
Dmitry Sevostyanov

UserPostedImage Follow Aurigma on Twitter!
bdavi19  
#3 Posted : Friday, August 25, 2006 12:55:29 AM(UTC)
bdavi19

Rank: Member

Groups: Member
Joined: 3/23/2006(UTC)
Posts: 14

I'm afraid that didn't work. I also tried passing it the _imgresult, but I still get the same error. Are there other possible solutions to this problem?

Thanks,

Brad
Dmitry  
#4 Posted : Sunday, August 27, 2006 7:11:36 PM(UTC)
Dmitry

Rank: Advanced Member

Groups: Member, Administration, Moderator
Joined: 8/3/2003(UTC)
Posts: 1,070

Thanks: 1 times
Was thanked: 12 time(s) in 12 post(s)
Hello,

It is very oddly... I have the following code sample and everything works fine:
Code:
Aurigma.GraphicsMill.Bitmap bmp = new Aurigma.GraphicsMill.Bitmap(@"d:/images/test/wizard.jpg");
try
{
	imageList1.Images.Add(bmp.ToGdiplusBitmap());
}
finally
{
	bmp.Dispose();
}

imageList1.Images[0].Save(@"d:/temp/1.png");

The problem of your previous code sample was in that you create System.Drawing.Bitmap on pixel data of Aurigma.GraphicsMill.Bitmap directly and than dispose Aurigma.GraphicsMill.Bitmap instance. So after that System.Drawing.Bitmap has no pixel data. That was a problem.

Could you rebuild all your project and try again? If it will not help - please submit case with your complete sample, which causes the problem.

Edited by user Thursday, May 22, 2008 9:57:50 PM(UTC)  | Reason: Not specified

Sincerely yours,
Dmitry Sevostyanov

UserPostedImage Follow Aurigma on Twitter!
Users browsing this topic
Forum Jump  
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.