RhinoCommon FileIO access to BitmapTable


#1

Any way to get access to this table via File IO.I can construct file3dm from external 3dm file and can loop through object table and then add object I want and the objects material to current active doc but if that material has a texture using external file that is no longer present but is indeed in the bitmap table of the file3dm (I deleted the actual bitmap file and made sure it was indeed embedded so opening file in rhino does show bitmap texture) no way for me to access that table to retrieve the bitmap.
Also be great to get PageViews from the FileIO as well.


(Dale Fugier) #2

I guess not. I’ll get this on the to-do list for a service release. Thanks for pointing this out.

– Dale


(Luis Fraguada) #3

Is there an update to this request? It seems there is not a way yet to get access to the file bitmap table. Is there another way to read the bitmaps embedded within a file from another application via Rhino3dmIO?


(Dale Fugier) #4

The YouTrack item is still open, so I’m assuming it hasn’t been worked on yet.

http://mcneel.myjetbrains.com/youtrack/issue/RH-28327

The only other option is to not use Rhino3dmIO but to use openNURBS (C++).


(Steve Baer) #5

Another option is to write the code yourself :smile:. It is really just a matter of me not having enough time in the day.

I would write this in the WIP branch and then back port it to V5 once complete. If you want to take this on, I can help you through the “hairy” pieces.


(Luis Fraguada) #6

As a conceptual thought exercise, is there even a way to get access to the data from RhinoCommon FileIO?


(Steve Baer) #7

I don’t think I understand this question, but I won’t let that stop me from writing a reply :smiling_imp:

The File3dm class is a direct wrapper around the OpenNURBS C++ ONX_Model class. That C++ class does have access to the bitmap list embedded in the 3dm file. No properties or functions have been written in File3dm (the c# code) to access these bitmaps yet.


(Luis Fraguada) #8

Yes, that is what I meant. How does that data exist, and what would be the entry point to get at it…

That gives me enough pointers to at least start to nose around. Thx.


#9

Any idea if this will make it into 6 release for RhinoCommon?


#10

Hi all. I’m jumping on this thread because I started to implement a File3dmBitmapTable class for standalone File3dm. So far I can read the table and get the BitmapEntry filename. When I try to read other things like Width, Height, and SizeOfImage or just tell the ON_EmbeddedBitmap to dump, everything is zero. Then I noticed lines 1053 - 1059 of opennurbs_bitmap.cpp:

> int ON_EmbeddedBitmap::Width() const {return 0;}
> int ON_EmbeddedBitmap::Height() const {return 0;}
> int ON_EmbeddedBitmap::BitsPerPixel() const {return 0;}
> int ON_EmbeddedBitmap::SizeofScan() const {return 0;}
> int ON_EmbeddedBitmap::SizeofImage() const {return 0;}
> unsigned char* ON_EmbeddedBitmap::Bits(int) {return 0;}
> const unsigned char* ON_EmbeddedBitmap::Bits(int) const {return 0;}

Is there a newer version of Opennurbs after 2013? Would anyone like to help with extracting the embedded bitmaps? Is there another way of doing this? Should I repost this in the Opennurbs section? I was hoping that I just had to hack on Rhino3dmIO and leave the native library alone. Sorry to dig up an old thread but any help would be appreciated.

Thx


#11

Ok sorry for freaking out just now. I was able to extract the file with a simple fwrite:

ON_EmbeddedBitmap* pBitmap = ON_EmbeddedBitmap::Cast( model.m_bitmap_table[0]);
FILE* pFile;
pFile = fopen("file.png", "wb");

fwrite(pBitmap->m_buffer, 1, pBitmap->m_sizeof_buffer, pFile);
		
fclose(pFile);

I can now implement BitmapEntry.Save()