VoidWhisperer Posted July 19, 2009 Share Posted July 19, 2009 This is my script: #region UICode byte Amount1=0; //[0,100]Slider 1 Description byte Amount2=0; //[0,100]Slider 2 Description byte Amount3=0; //[0,100]Slider 3 Description #endregion void Render(Surface dst, Surface src, Rectangle rect) { // Delete any of these lines you don't need Rectangle selection = this.EnvironmentParameters.GetSelection(src.Bounds).GetBoundsInt(); long CenterX = (long)(((selection.Right - selection.Left) / 2)+selection.Left); long CenterY = (long)(((selection.Bottom - selection.Top) / 2)+selection.Top); ColorBgra PrimaryColor = (ColorBgra)EnvironmentParameters.PrimaryColor; ColorBgra SecondaryColor = (ColorBgra)EnvironmentParameters.SecondaryColor; int BrushWidth = (int)EnvironmentParameters.BrushWidth; ColorBgra CurrentPixel; for (int y = rect.Top; y < rect.Bottom; y++) { for (int x = rect.Left; x < rect.Right; x++) { CurrentPixel = src[x,y]; // TODO: Add pixel processing code here // Access RGBA values this way, for example: CurrentPixel.R = (byte)Amount1; CurrentPixel.G = (byte)Amount2; CurrentPixel.B = (byte)Amount3; CurrentPixel.A = (byte)PrimaryColor.A; dst[x,y] = CurrentPixel; } } } I keep getting a error saying it can't change an int into a byte, but It shouldn't have to.. I need help! Quote Link to comment Share on other sites More sharing options...
Simon Brown Posted July 19, 2009 Share Posted July 19, 2009 Try removing the unneeded casting. Quote Link to comment Share on other sites More sharing options...
VoidWhisperer Posted July 19, 2009 Author Share Posted July 19, 2009 #region UICode byte Amount1=0; //[0,100]Slider 1 Description byte Amount2=0; //[0,100]Slider 2 Description byte Amount3=0; //[0,100]Slider 3 Description #endregion void Render(Surface dst, Surface src, Rectangle rect) { // Delete any of these lines you don't need Rectangle selection = this.EnvironmentParameters.GetSelection(src.Bounds).GetBoundsInt(); long CenterX = (long)(((selection.Right - selection.Left) / 2)+selection.Left); long CenterY = (long)(((selection.Bottom - selection.Top) / 2)+selection.Top); ColorBgra PrimaryColor = (ColorBgra)EnvironmentParameters.PrimaryColor; ColorBgra SecondaryColor = (ColorBgra)EnvironmentParameters.SecondaryColor; int BrushWidth = (int)EnvironmentParameters.BrushWidth; ColorBgra CurrentPixel; for (int y = rect.Top; y < rect.Bottom; y++) { for (int x = rect.Left; x < rect.Right; x++) { CurrentPixel = src[x,y]; // TODO: Add pixel processing code here // Access RGBA values this way, for example: CurrentPixel.R = Amount1; CurrentPixel.G = Amount2; CurrentPixel.B = Amount3; CurrentPixel.A = PrimaryColor.A; dst[x,y] = CurrentPixel; } } } still giving me that same error. Quote Link to comment Share on other sites More sharing options...
VoidWhisperer Posted July 19, 2009 Author Share Posted July 19, 2009 It will build, But when I try to save it as a DLL, I get the errors. Quote Link to comment Share on other sites More sharing options...
Simon Brown Posted July 19, 2009 Share Posted July 19, 2009 Are you using Vista? Quote Link to comment Share on other sites More sharing options...
VoidWhisperer Posted July 19, 2009 Author Share Posted July 19, 2009 I'm using XP. Quote Link to comment Share on other sites More sharing options...
Simon Brown Posted July 19, 2009 Share Posted July 19, 2009 Are you logged-in as admin? Quote Link to comment Share on other sites More sharing options...
VoidWhisperer Posted July 19, 2009 Author Share Posted July 19, 2009 Yes. Quote Link to comment Share on other sites More sharing options...
VoidWhisperer Posted July 19, 2009 Author Share Posted July 19, 2009 I really want to fix this <_> Quote Link to comment Share on other sites More sharing options...
Simon Brown Posted July 19, 2009 Share Posted July 19, 2009 What errors do you get? Quote Link to comment Share on other sites More sharing options...
VoidWhisperer Posted July 19, 2009 Author Share Posted July 19, 2009 Error at line 125: Cannot implicitly convert type 'int' to 'byte'. An explicit conversion exists (are you missing a cast?) (CSO266) Thats one of the 3 (They are all the same) Quote Link to comment Share on other sites More sharing options...
VoidWhisperer Posted July 19, 2009 Author Share Posted July 19, 2009 The thing I don't understand: They are bytes already... Quote Link to comment Share on other sites More sharing options...
BoltBait Posted July 19, 2009 Share Posted July 19, 2009 If you are using codelab, you can't just retype the variables in the UICode block and expect it to work. I think this is what you're after: #region UICode int Amount1=0; //[0,255]Slider 1 Description int Amount2=0; //[0,255]Slider 2 Description int Amount3=0; //[0,255]Slider 3 Description #endregion void Render(Surface dst, Surface src, Rectangle rect) { ColorBgra CurrentPixel; for (int y = rect.Top; y { for (int x = rect.Left; x { CurrentPixel = src[x,y]; // TODO: Add pixel processing code here // Access RGBA values this way, for example: CurrentPixel.R = (byte)Amount1; CurrentPixel.G = (byte)Amount2; CurrentPixel.B = (byte)Amount3; // CurrentPixel.A = (byte)PrimaryColor.A; dst[x,y] = CurrentPixel; } } } You see, CodeLab writes a bunch of code for you for the UI stuff all based on the types of variables in the UICode block. Don't edit those unless you know what you're doing. It is probably best if you stick to using CodeLab's built-in UI designer (Ctrl-I). Quote Download: BoltBait's Plugin Pack | CodeLab | and a Free Computer Dominos Game Link to comment Share on other sites More sharing options...
VoidWhisperer Posted July 19, 2009 Author Share Posted July 19, 2009 THANKS BOLT! =) Quote Link to comment Share on other sites More sharing options...
Simon Brown Posted July 19, 2009 Share Posted July 19, 2009 Try using ints instead of bytes for the sliders. #region UICode int Amount1=0; //[0,100]Slider 1 Description int Amount2=0; //[0,100]Slider 2 Description int Amount3=0; //[0,100]Slider 3 Description #endregion void Render(Surface dst, Surface src, Rectangle rect) { // Delete any of these lines you don't need Rectangle selection = this.EnvironmentParameters.GetSelection(src.Bounds).GetBoundsInt(); long CenterX = (long)(((selection.Right - selection.Left) / 2)+selection.Left); long CenterY = (long)(((selection.Bottom - selection.Top) / 2)+selection.Top); ColorBgra PrimaryColor = (ColorBgra)EnvironmentParameters.PrimaryColor; ColorBgra SecondaryColor = (ColorBgra)EnvironmentParameters.SecondaryColor; int BrushWidth = (int)EnvironmentParameters.BrushWidth; ColorBgra CurrentPixel; for (int y = rect.Top; y < rect.Bottom; y++) { for (int x = rect.Left; x < rect.Right; x++) { CurrentPixel = src[x,y]; // TODO: Add pixel processing code here // Access RGBA values this way, for example: CurrentPixel.R = (byte)Amount1; CurrentPixel.G = (byte)Amount2; CurrentPixel.B = (byte)Amount3; CurrentPixel.A = (byte)PrimaryColor.A; dst[x,y] = CurrentPixel; } } } Edit: Beaten. Quote Link to comment Share on other sites More sharing options...
APShredder Posted July 29, 2009 Share Posted July 29, 2009 Hey guys maybe you can help me too. I'm getting the same error messages as VoidWhisper, and I've tried everything I can think of to get rid of them, no so far I've done nothing. Maybe you can help. Here's my code: #region UICode int rbc = 0; // [-255,255] Red Boost/Cut int gbc = 0; // [-255,255] Green Boost/Cut int bbc = 0; // [-255,255] Blue Boost/Cut #endregion void Render(Surface dst, Surface src, Rectangle rect) { ColorBgra CurrentPixel; for (int y = rect.Top; y < rect.Bottom; y++) { for (int x = rect.Left; x < rect.Right; x++) { CurrentPixel = src[x,y]; // TODO: Add pixel processing code here // Access RGBA values this way, for example: CurrentPixel.R = (byte)CurrentPixel.R + (byte)rbc; CurrentPixel.G = (byte)CurrentPixel.G + (byte)gbc; CurrentPixel.B = (byte)CurrentPixel.B + (byte)bbc; dst[x,y] = CurrentPixel; } } } Quote BlendModes Plus | Dissolve | Extract Color Link to comment Share on other sites More sharing options...
BoltBait Posted July 29, 2009 Share Posted July 29, 2009 Stay out of the UICode block. You can't just start editing those lines if you don't know what CodeLab is going to do with them. The variable names MUST be Amount1, Amount2, Amount3... Also, you're going to quickly overflow your R, G, and B values. Better to clamp them to a byte range: #region UICode int Amount1 = 0; // [-255,255] Red Boost/Cut int Amount2 = 0; // [-255,255] Green Boost/Cut int Amount3 = 0; // [-255,255] Blue Boost/Cut #endregion void Render(Surface dst, Surface src, Rectangle rect) { ColorBgra CurrentPixel; for (int y = rect.Top; y { for (int x = rect.Left; x { CurrentPixel = src[x,y]; // TODO: Add pixel processing code here // Access RGBA values this way, for example: CurrentPixel.R = Utility.ClampToByte(CurrentPixel.R + Amount1); CurrentPixel.G = Utility.ClampToByte(CurrentPixel.G + Amount2); CurrentPixel.B = Utility.ClampToByte(CurrentPixel.B + Amount3); dst[x,y] = CurrentPixel; } } } There! That should work. Quote Download: BoltBait's Plugin Pack | CodeLab | and a Free Computer Dominos Game Link to comment Share on other sites More sharing options...
APShredder Posted July 29, 2009 Share Posted July 29, 2009 Thanks BoltBait, works like a charm now. Quote BlendModes Plus | Dissolve | Extract Color Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.