Jump to content

Adding file types to a Plugin File Dialog


NeilMacG

Recommended Posts

Firstly - apologies for generic title on previous post. I susbscribe to lots of forums and haven't seen that one before. Ooops.

Hi I'm new to Paint.net but it does seem to be an excellent program. There is a plugin to enable RAW files to be loaded (Rawloader) but the default compiled code does not include support for Pentax .pef files although the converter that it uses (DCRAW) does.

Others have mentioned being able to use Visual Studio c# Express to modify the file open dialog to enable .pef files to be converted.

I'm an experienced VBA/VBScript programmer and have a vague awareness of c derivate program languages but this is first time I've wanted to do something in earnest with a c# program.

My slghtly modified copy of the source code is shown below However when I try to build the project I get an error as follows:

Error 1 'PaintDotNet.FileType.FileType(string, bool, bool, bool, bool, bool, string[])' is obsolete: 'Use the FileType(string, FileTypeFlags, string[]) overload instead' C:\Downloads\PhotoEditing\RawLoaderSource\RawLoader\RawLoader.cs 21 10 RawLoader

All I've done is add the .pef extension into the line commented //extensions. Can anyone help me understand why it won't compile even though I had understood it was originally compiled with the same c# compiler.

Possibly I need training in c# but I've looked at the tutorials and the language generally makes sense to me, but I'm hoping it's something reasonably simple to sort this out. If not can anyone suggest some reading material to help with this particular aspect of the language.

Many thanks - Neil

****************Source Code*****************************

using System;

using System.IO;

using System.Configuration;

using System.Windows.Forms;

using PaintDotNet;

namespace RawLoader

{

public class RAWFileTypes : IFileTypeFactory

{

public static readonly FileType Raw = new RawFileType();

private static FileType[] fileTypes = new FileType[] { Raw };

public FileType[] GetFileTypeInstances()

{

return (FileType[])fileTypes.Clone();

}

}

public class RawFileType : FileType

{

private String runpath, arguments;

public RawFileType() : base( "Raw Camera Images",

false, // does not support layers

false, // does not support custom headers

false, // does support saving

true, // does support loading

false, // does not save with progress

new string[] { ".pef", ".dng", ".nef", ".crw", ".cr2", ".mrw", ".raf", ".x3f", ".orf", ".raw" } ) // extensions

{

}

protected override Document OnLoad(System.IO.Stream input)

{

MemoryStream TiffStream = new MemoryStream();

// Load Settings

runpath = ConfigurationManager.AppSettings["path"];

if (runpath == null) runpath = "dcraw.exe";

arguments = ConfigurationManager.AppSettings["arguments"];

if (arguments == null) arguments = "-w -q 3 -n 3";

// Write Stream to temporary file

using (TempFile RawFile = new TempFile())

{

RawFile.WriteStream(input);

// Run DCRaw and capture its StandardOutput into temporary Tiff memory stream

ProcessOutput DCRaw = new ProcessOutput(runpath, arguments + " -c -T \"" + RawFile.Path + "\"");

StreamUtils.ReadWriteStream(DCRaw.Stream,TiffStream);

DCRaw.WaitForExit();

}

// Use default Tiff loader to load from Tiff memory stream

TiffStream.Position = 0;

FileType TiffHandler = PdnFileTypes.Tiff;

return TiffHandler.Load(TiffStream);

}

}

}

The Sky is a Beautiful Place

Sig2.jpg

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...