Rank: Member
Groups: Member
Joined: 11/27/2003(UTC) Posts: 29
|
The following code is giving me an invalid cast error message Code: Dim hist(255) As Long
hist = gm.Data.GetHistogram(GraphicsMill.Channel.ChannelAll)
All I'm trying to do is get the histogram. The GM object has been used for other funcitons to this point, so I know it is okay. Also Code: Dim hist() As Long
hist = gm.Data.GetHistogram(GraphicsMill.Channel.ChannelAll)
gives me the same message Edited by user Monday, December 24, 2007 6:08:52 PM(UTC)
| Reason: Not specified |
Tom Thorp Still waters, great photos
|
|
|
|
Rank: Advanced Member
Groups: Member, Administration Joined: 8/2/2003(UTC) Posts: 876
Thanks: 2 times Was thanked: 27 time(s) in 27 post(s)
|
Histogram is returned as an array of VARIANTs (to be able to work with it in ASP). That's why you should try to declare an non-typed array (or array of objects):
Dim hist(255) hist = objBitmap.Data.GetHistogram(GraphicsMill.Channel.ChannelAll)
|
|
|
|
Rank: Member
Groups: Member
Joined: 11/27/2003(UTC) Posts: 29
|
It works. Thanks
The only problem is that this generates some "untyped" code which is a little bit against how things are suppose to work in .NET. Also, because it is "untyped", it runs some slower. |
Tom Thorp Still waters, great photos
|
|
|
|
Rank: Advanced Member
Groups: Member, Administration Joined: 8/2/2003(UTC) Posts: 876
Thanks: 2 times Was thanked: 27 time(s) in 27 post(s)
|
Unfortunately untyped array is unavoidable in this situation. However if you use histograms array heavily, and it adversely affect the performance, you can copy this array into array of Long. Something like this: Code:Dim hist(255)
hist = objBitmap.Data.GetHistogram(Aurigma.GraphicsMill.Channel.ChannelAll)
Dim histLong(255) As Long
Dim I As Long
For I = LBound(hist) To UBound(hist)
histLong(I) = hist(I)
Next I
It should not give big overhead, especially if you access this array many times. But of course, if you need to fulfill single pass through its items, it makes no sense. Edited by user Monday, December 24, 2007 6:09:04 PM(UTC)
| Reason: Not specified
|
|
|
|
Rank: Advanced Member
Groups: Member, Administration, Moderator Joined: 7/28/2003(UTC) Posts: 1,660
Thanks: 5 times Was thanked: 76 time(s) in 74 post(s)
|
|
Best regards, Fedor Skvortsov
|
|
|
|
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.