Visual Basic .NET Forums  
Click here to advertise with us

Go Back   Visual Basic .NET Forums > VB.NET > Graphics/GDI+

Graphics/GDI+ Graphics discussion for VB.NET applications, Winforms, Web, Compact Framework, etc.

VB.NET Forums Newsletter Signup:
Email address:


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-09-2009, 2:07 PM
VB.NET Forum Newbie
.NET Framework: .NET 2.0 (VS 2005)
 
Join Date: Jul 2009
Age: 31
Posts: 2
Reputation: 0
xuser is on a distinguished programming path ahead
Question Image losing PropertyItems when adding to ImageList

I'm stumped... As soon as an Image with PropertyItems is put into the ImageList, it appears to lose that data. Anyone know why this is happening and how to resolve it?

Code:
' il is of type ImageList; img is of type Image.
MsgBox(img.PropertyItems.Length) ' Length = 68
il.Images.Add(img)
MsgBox(il.Images(0).PropertyItems.Length) ' Length = 0
MsgBox(img.Clone.PropertyItems.Length) ' Length = 68
il.Images(0) = img.Clone
MsgBox(il.Images(0).PropertyItems.Length) ' Length = 0
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 07-09-2009, 3:33 PM
VB.NET Forum Newbie
.NET Framework: .NET 2.0 (VS 2005)
 
Join Date: Jul 2009
Age: 31
Posts: 2
Reputation: 0
xuser is on a distinguished programming path ahead
Default

I don't get it... This doesn't work either.

Code:
For Each origProp As PropertyItem In img.PropertyItems
    il.Images.Item(0).SetPropertyItem(origProp)
Next
MsgBox(il.Images(0).PropertyItems.Length) ' Length = 0
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 07-12-2009, 11:21 PM
jmcilhinney's Avatar
VB.NET Forum Moderator
.NET Framework: .NET 3.5 (VS 2008)
 
Join Date: Aug 2004
Location: Sydney, Australia
Age: 40
Posts: 6,118
Reputation: 541
jmcilhinney VB.NET gold medalistjmcilhinney VB.NET gold medalistjmcilhinney VB.NET gold medalistjmcilhinney VB.NET gold medalistjmcilhinney VB.NET gold medalistjmcilhinney VB.NET gold medalistjmcilhinney VB.NET gold medalistjmcilhinney VB.NET gold medalistjmcilhinney VB.NET gold medalistjmcilhinney VB.NET gold medalistjmcilhinney VB.NET gold medalist
Default

I just ran this code:
Code:
Dim img = Image.FromFile(filePath)

Me.ImageList1.Images.Add(img)
MessageBox.Show((img Is Me.ImageList1.Images(0)).ToString)
and got False, i.e. the Image object I added to the ImageList is not the Image stored in the ImageList. A new Image object is created based on the image properties defined by the ImageList. I don't know whether that is always the case but it obviously is in some cases at least. The documentation for the Image.PropertyItems property says:
Quote:
If the image has no property items or if the image format does not support property items, PropertyItems returns an empty array (that is, an array of length zero).
Presumably the image format supported by your ImageList doesn't support property items.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks

Tags
gps, image, imagelist, propertyitems


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





All times are GMT -4. The time now is 6:08 PM.

Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2


For advertising opportunities click here.