Jump to content

MikeFr

Newbies
  • Posts

    2
  • Joined

  • Last visited

Everything posted by MikeFr

  1. Humm, if you're right, the only way for me to save image in my custom format is to export C function directly in C#. Thanks for the answers!!
  2. hi there! I just develop a new file format and the associated WIC codec. Now I'm trying to develop the paint.NET File Type plugins to open and SAVE in my format into PDN. I succeed to open an image in PDN with the function onLoad : protected override Document OnLoad(Stream input) { try { BitmapSource bitmapSourcetest = null; MemoryStream imageStream = null; BitmapCreateOptions createOptions = BitmapCreateOptions.PreservePixelFormat | BitmapCreateOptions.IgnoreColorProfile; BitmapDecoder myDecoder = BitmapDecoder.Create(input, createOptions, BitmapCacheOption.None); if (myDecoder.Frames[0] != null) { bitmapSourcetest = myDecoder .Frames[0]; } //Save the image in a Memory stream System.Windows.Media.Imaging.BmpBitmapEncoder bmpEncoder = new System.Windows.Media.Imaging.BmpBitmapEncoder(); bmpEncoder.Frames.Add(System.Windows.Media.Imaging.BitmapFrame.Create(bitmapSourcetest)); imageStream = new MemoryStream(); bmpEncoder.Save(imageStream); Bitmap b = new System.Drawing.Bitmap(imageStream); myContainerFormat = myDecoder.CodecInfo.ContainerFormat; return Document.FromImage(; } catch { MessageBox.Show("Problem Importing File"); Bitmap b = new Bitmap(500, 500); return Document.FromImage(; } } BitmapDecoder.Create creates the decoder by calling the wic dll. and myContainerFormat gives me the correct GUID container format. Now it's getting more complicated with the method onSave. I try this code : protected override void OnSave(Document input, Stream output, SaveConfigToken token, Surface scratchSurface, ProgressEventHandler callback) { myEncoder = BitmapEncoder.Create(myContainerFormat); myEncoder.Save(output); /*using (RenderArgs ra = new RenderArgs(scratchSurface)) { input.Render(ra, true); ra.Bitmap.Save(output, ImageFormat.Bmp); }*/ } I can't create the encoder based on my wic dll it always return an UnknownBitmapEncoder. Anyone as a clue on using the WIC with PDN ???? Thanks for answers. Mike
×
×
  • Create New...