Category Color/RGB to Image/Bitmap

Category Color/RGB to Image/Bitmap

stefan.palm
Advocate Advocate
1,213 Views
6 Replies
Message 1 of 7

Category Color/RGB to Image/Bitmap

stefan.palm
Advocate
Advocate

dim cat = Connection.CategoryManager.FindCategory(category.Id)

cat .Color.R

cat .Color.G

cat .Color.B

How do i convert the color/rgb values to an in memory image/bitmap object?

Or should one get the icon/image associated with an entity category from some place else?

 

 

Thanks

 

0 Likes
Accepted solutions (1)
1,214 Views
6 Replies
Replies (6)
Message 2 of 7

sajith_subramanian
Autodesk Support
Autodesk Support

Hi @stefan.palm ,

 

If you are using a VaultBrowserControl, and want to show the category icon in a column, you can make use of the CategoryGlyph property like below:. This should show up the icon in the grid.

 

initialConfig.AddInitialColumn(VDF.Vault.Currency.Properties.PropertyDefinitionIds.Server.CategoryGlyph);

 

 

If you are however interested to extract the image, please use the below code:

 

 PropertyDefinitionDictionary props = m_conn.PropertyManager.GetPropertyDefinitions(
     VDF.Vault.Currency.Entities.EntityClassIds.Files,null, PropertyDefinitionFilter.IncludeAll);

PropertyDefinition catProp = props[PropertyDefinitionIds.Server.CategoryGlyph];
ImageInfo category= m_conn.PropertyManager.GetPropertyValue(Fileiteration, catProp, null) as ImageInfo; Image img = category.GetImage(); // System.Drawing.Image object

Hope this helps.

 

 

Regards,

Sajith


Sajith Subramanian
Autodesk Developer Network
0 Likes
Message 3 of 7

stefan.palm
Advocate
Advocate

And if i only have the category object, is it possible to get the image via the category itself an not via the iEntity object? If not i am basically forced to find an entity that is categorized to the category ID i want to get the image for?

 

Thanks

0 Likes
Message 4 of 7

sajith_subramanian
Autodesk Support
Autodesk Support
Accepted solution

Hi @stefan.palm ,

 

In that case, you can use something similar as below:

 

 

  EntityCategory entCat = 
         m_conn.CategoryManager.FindCategory(category.Id);
  ImageInfo imginfo = 
         m_conn.CategoryManager.GetCategoryGlyph(entCat);
  Image img = imginfo.GetImage();

 

Regards,

Sajith

 

 


Sajith Subramanian
Autodesk Developer Network
0 Likes
Message 5 of 7

stefan.palm
Advocate
Advocate

I get an error "object reference not set to an instance of an object" on this line of code 

ImageInfo imginfo = 
         m_conn.CategoryManager.GetCategoryGlyph(entCat);

It makes no sence since i do get back the category entity using "FindCategory".

 

0 Likes
Message 6 of 7

sajith_subramanian
Autodesk Support
Autodesk Support

Hi @stefan.palm ,

 

Could you share your compilable code here (only if non confidential). I would like to execute your code on my machine to see if I can reproduce the issue.

 

Regards,

Sajith


Sajith Subramanian
Autodesk Developer Network
0 Likes
Message 7 of 7

stefan.palm
Advocate
Advocate

i created a new project for upload but the same code do work in there. So it must be something in my bigger project that makes this error occur? I have a lot of code in it and it all works fine except this get category icon function.  I guess i have to try to figure out why my self since i can not upload that project. 

 

0 Likes