Jump to content

Opening a file from within a plugin


jpmorganuk
 Share

Recommended Posts

I want to create a plugin that takes an image at one location and loads it into a layer, then takes another image and loads it into a higher layer.

The first issue is how to tell paint .net where my two files are. I was hoping to do this by passing a file location to a parameter for each file, eg, a dialog box where I enter "C:\..../myfile.jpg". I can get the file location fine. However, I do nto know the commands I need to open the file into my plugin? Can you point me in the direction of some example code please?

The second issue is resizing the images. Again, do you know of any examples of code or in-built functions that I can call to resize an image?

Thanks in advance for any help.

Paul

Link to comment
Share on other sites

Thank you for the clarification. Based on your feedback I have changed my design slightly. I now want to create a plugin that loads in an image from a file, then loads another image from a seperate file, and then overlays the second image over part of the first, then loads it into the current layer.

My first issue is I do not know how to open the files from within the code. I can use a dialog box when the plug in is called where the users enters "C:\..../myfile.jpg" (the address of each file). This is no problem using the CodeLab plugin. However, I do not know the commands I need to then open each file into my plugin, so I can manipulate the image file and add it it to my current image. Can you point me in the direction of some example code please?

The second issue is resizing the images. Again, do you know of any examples of code or in-built functions that I can call to resize an image once loaded into memory?

Thanks in advance for any help.

Paul

Link to comment
Share on other sites

Have a look at File and FileStream - and then don't use that, there are easier ways.

(quick idea)

You could easily load the image and resize it like so: new Bitmap(new Bitmap("path/to/file"), width, height)

Then copy the bitmap onto the current layer of course (I wouldn't use unsafe code just yet, do that when you're familiar with it)

(/quick idea)

I would write plugins, if I knew what kind of plugins were needed.. :(

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.

 Share

×
×
  • Create New...