[Closed] Interface/abstract class problem, dotnet
Hi,
I’m trying to extract the frames of a .gif-file in mxs, using dotnet for the first time, but I’m having trouble with assigning the frames to BitmapSources. Do I have to create a BitmapSource class? Is there something different you would have to do when dealing with abstract classes/interfaces in mxs?
I try to follow the first example in this link: bitmapdecoder.aspx
fn extractFrames theGif =
(
local fs = dotNetObject (dotNetClass "System.IO.FileStream" ) theGif \
(dotNetClass "System.IO.FileMode").Open \
(dotNetClass "System.IO.FileAccess").Read \
(dotNetClass "System.IO.FileShare").Read
local decoder = dotNetObject (dotNetClass "System.Windows.Media.Imaging.GifBitmapDecoder") fs \
(dotNetClass "System.Windows.Media.Imaging.BitmapCreateOptions").PreservePixelFormat \
(dotNetClass "System.Windows.Media.Imaging.BitmapCacheOption").Default
for frame = 1 to decoder.Frames.Count do
(
--local bmSource = getProperty decoder #Frames[frame] dont work
--local bmSource = decoder.Frames[frame] dont work
--rest of the code here..
)
)
This is my first run with dotnet in mxs so I hope I haven’t missed something essential.
I just quickly read the documentation. It seems like a frame is an instance of the BitmapSource class. At the moment you are trying to store the instance(frame) in a maxscript value which cannot be done. What are you trying to do with the pixel data? Are you trying to display the separate frames. If you are, you could create an create instances of the .net image class and assign the separate frames to them. The image instances could then be displayed in a .net form. Explain further what you are trying to do.
Jamell
One thing I am confused about is the fact that BitmapSource and BitmapFrame are both stated as being abstract which you shouldn’t be able to instantiate but in the example you linked to an instance of the BitmapSource is created. I think I’m missing something!
To answer your question, I want to read the color value of each pixel for each frame to use in this script. It creates boxes on each pixel for each frame so you can see an animated voxeled version of the image. It works with image sequences and small movie-files but not with an animated .gif, as far as I know I can only access the first frame of a .gif in vanilla mxs. So to sum it up, I just want to access each frame’s image data.
I think that method will do it yeah, but I still need to get the image into a BitmapSource right?
No because BitmapFrame (the type of the frames in the decoder) inherits from BitmapSource so should have the CopyPixels method. Create a System.Array to store the pixel data then pass it to decoder.Frames[frame].CopyPixels.
Jamell