Paint.NET

Welcome to the Paint.NET forum!
It is currently Wed Nov 25, 2009 7:31 am

All times are UTC




Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: Unassigned Local Variable Error
PostPosted: Tue Nov 03, 2009 9:50 pm 
Offline
User avatar

Joined: Fri Jun 26, 2009 2:11 am
Posts: 928
Location: Massachusetts
I am trying to add a feature to my BlendModes Plus plugin that would allow the user to copy a picture overfrom the clipboard. The only problem is when try to build the plugin I get errors the say "Use of unassigned local variable" and Use of possibly unassigned field". I can't get rid of them and I'm going crazy trying. Help would be greatly appreciated, and the source is attached below. Thanks in advance. :D

BlendMode Plus Source

_________________
Image


Top
 Profile  
 
 
 Post subject: Re: Unassigned Local Variable Error
PostPosted: Tue Nov 03, 2009 9:57 pm 
Offline
2008 "WEOMPA Award" and "Howard Hughes Award for Eccentricity" (Winner?)
User avatar

Joined: Mon Nov 05, 2007 6:20 pm
Posts: 8698
Location: UK
What line number is it giving you?

Also, are you sure a RadioButton is the best choice? If the user checks it and the clipboard contents change, it appears as if BMP is using the clipboard when it is no longer dependent on it.

Edit: ...or IMO shouldn't be.


Why are you reading the clipboard in a method that is called constantly by Paint.NET?

_________________
Image
Wave Username: simonbrown60


Top
 Profile  
 
 Post subject: Re: Unassigned Local Variable Error
PostPosted: Tue Nov 03, 2009 10:02 pm 
Offline
2008 "WEOMPA Award" and "Howard Hughes Award for Eccentricity" (Winner?)
User avatar

Joined: Mon Nov 05, 2007 6:20 pm
Posts: 8698
Location: UK
My suggestion is to create a separate control for the image being used (containing a picturebox) and have buttons to copy either the clipboard or a file into it.

Hope this helps.

_________________
Image
Wave Username: simonbrown60


Top
 Profile  
 
 Post subject: Re: Unassigned Local Variable Error
PostPosted: Tue Nov 03, 2009 10:05 pm 
Offline
User avatar

Joined: Fri Jun 26, 2009 2:11 am
Posts: 928
Location: Massachusetts
I'm getting errors at lines: 38, 114, 120, 121, 122, 123, 148, 149, 150, 368, 419, and 421.

And about the radio button, I see what you're saying and I'm kind of balancing the pros and cons of changing it right now, so I'll see what I'll do about it in a little bit. Oh, and thanks for your help. :)

EDIT: I'm not sure what you mean about constantly calling the clipboard method. Could you explain? Is there a better way to do it?

_________________
Image


Top
 Profile  
 
 Post subject: Re: Unassigned Local Variable Error
PostPosted: Tue Nov 03, 2009 10:14 pm 
Offline
2008 "WEOMPA Award" and "Howard Hughes Award for Eccentricity" (Winner?)
User avatar

Joined: Mon Nov 05, 2007 6:20 pm
Posts: 8698
Location: UK
To fix the "unassigned" build error (or at least some of them), give variables that you only assign in parenthesis a default value.

_________________
Image
Wave Username: simonbrown60


Last edited by Simon Brown on Tue Nov 03, 2009 10:17 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Unassigned Local Variable Error
PostPosted: Tue Nov 03, 2009 10:17 pm 
Offline
2008 "WEOMPA Award" and "Howard Hughes Award for Eccentricity" (Winner?)
User avatar

Joined: Mon Nov 05, 2007 6:20 pm
Posts: 8698
Location: UK
APShredder wrote:
EDIT: I'm not sure what you mean about constantly calling the clipboard method. Could you explain? Is there a better way to do it?


A tradeoff would be to copy the contents into a global variable in OnSetRenderInfo(), although I urge you to avoid being dependent on the clipboard, such as by having the clipboard as just one way of importing the image into the token (from the dialog) without dependencies.

_________________
Image
Wave Username: simonbrown60


Top
 Profile  
 
 Post subject: Re: Unassigned Local Variable Error
PostPosted: Tue Nov 03, 2009 10:21 pm 
Offline
User avatar

Joined: Fri Jun 26, 2009 2:11 am
Posts: 928
Location: Massachusetts
Do you mean curly brackets, because I'm pretty sure I don't have any variables assign in parenthesis.

EDIT: Oh, and thanks for explaining about the clipboard thing. I get what you're saying now.

_________________
Image


Top
 Profile  
 
 Post subject: Re: Unassigned Local Variable Error
PostPosted: Tue Nov 03, 2009 10:24 pm 
Offline
2008 "WEOMPA Award" and "Howard Hughes Award for Eccentricity" (Winner?)
User avatar

Joined: Mon Nov 05, 2007 6:20 pm
Posts: 8698
Location: UK
Code:
                        if (token.FromClipboard == true && token.SwapLayers == false)

                        {

                            CP = srcArgs.Surface[x, y];

                            LCP = Surface.CopyFromBitmap(ClipboardImage)[x,y];

                            CPHSV = HsvColor.FromColor(Color.FromArgb(CP.A, CP.R, CP.G, CP.B));

                            LCPHSV = HsvColor.FromColor(Color.FromArgb(LCP.A, LCP.R, LCP.G, LCP.B));

                        }


...but there's no value set outside of the brackets (in case the contents aren't run - one set will be but the compiler doesn't know that).

_________________
Image
Wave Username: simonbrown60


Top
 Profile  
 
 Post subject: Re: Unassigned Local Variable Error
PostPosted: Tue Nov 03, 2009 10:28 pm 
Offline
User avatar

Joined: Fri Jun 26, 2009 2:11 am
Posts: 928
Location: Massachusetts
Thanks Simon, that got rid of all the errors. Now all I have to do is take care of the clipboard thing, which i think I can take care of myself. Once again, thanks for your help. :D

_________________
Image


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Hosted by Forumer & phpBB

Get your Forumer™ today!

Adding a forum to your website is a great way to get return visitors.

» Get your own Free Forum!

Terms of Use

Privacy Policy

Report Abuse

Copyright © 2003-2009 Forumer. All Rights Reserved. | Copyright © paint.NET