Jump to content

black2hack

Members
  • Posts

    16
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

black2hack's Achievements

Apprentice

Apprentice (3/14)

  • First Post
  • Collaborator
  • Conversation Starter
  • Week One Done
  • One Month Later

Recent Badges

0

Reputation

  1. Hey, thank you pal. I've been occupied by different annoying stuff (like my studies ^_^) so I kinda neglected my work with this plugin. I hope I'll be able to find time to cope with Teh BUG soon. I also have some ideas for a new plugin. Though there is a high probability I'll never start doing it =)
  2. I read this before and I'd like to see more detailed explanation.
  3. 2pdnnoob. Thank you, I'll do my best =) 2yellowman. Yes. Max Angle defines a maximum angle of random rotations of fragments, Fluctuation defines maximum deviation of fragments from regular rectangles. The more size of a picture and a count of fragments the more time of rendering. I gotta make ROI system work. When I do it rendering process will be much faster. Btw, I still don't understand how ROI actually works and why it reduces time of rendering. If you wish to explain it, please follow here and leave your message after the beep.
  4. Thank you for comments. I'll continue working at the plugin next weekend and will try to make it better. 2yellowman. No, it's a different effect. Firstly, fragments can be not only regular rectangles. Seconly, fragments are unaffected parts of an initial picture.
  5. You mean nothing happens until you click OK? Yep, but taking into account speed of the rendering in this beta it's not an issue =) Though I've just realized the way to make it better. I'll fix it.
  6. Hello! It's my first Paint.NET plugin. It's not complete yet but it works (to a greater or lesser extent) and I'd like to show what I've done. The main point of the plugin is easy - it shatters a picture to fragments. Fragments are placed on a rectangle matrix. The plugin's config has 5 parameters: Count of Columns = number of columns of a matrix of fragments (integer, >=1) Count of Rows = number of rows of a matrix of fragments (integer, >=1) Shifting (pixels) shows a distance between fragments (integer, >=0) Fluctuation (%) shows how much fragments differ from rectangle (integer, >=0, <=100) Max Angle (degrees) shows how much fragments rotate (integer) In this plugin I've used Interpolation function I had found in AdvancedRotate plugin by Stuart Radforth. Stuart, I hope you don't mind. Please, don't forget it's only a beta version! The general disadvantages are it has no anti-antialiasing and it works slow. VERY SLOW I mean . You can help me to cope with the second problem here, I'd really appreciate it. Good news is the plugin has no bugs as far as I know. Enjoy! Shatters_0.55beta.zip
  7. And after less than a month I've returned to my plugin © =) 2pyrochild. Thank you, I've found Error List in View -> Other windows -> Error List. I've received evidence that The BUG is caused by ROI. When I delete ROI everything works - slowly but correctly. I've attached a piece of code (C# now) just in case someone can find a problem faster than me. I suspect the problem is similar to this one http://forums.getpai...ing-to-pdn-336/ but I haven't understood this topic yet. public override void Render(EffectConfigToken parameters, RenderArgs dstArgs, RenderArgs srcArgs, Rectangle[] rois, int startIndex, int length) { PdnRegion selectionRegion = EnvironmentParameters.GetSelection(srcArgs.Bounds); //Surface src = srcArgs.Surface; //Surface dst = dstArgs.Surface; Rectangle selection = EnvironmentParameters.GetSelection(srcArgs.Surface.Bounds).GetBoundsInt(); int CenterX = ((selection.Right - selection.Left) / 2) + selection.Left; int CenterY = ((selection.Bottom - selection.Top) / 2) + selection.Top; ColorBgra PrimaryColor = (ColorBgra)EnvironmentParameters.PrimaryColor; ColorBgra SecondaryColor = (ColorBgra)EnvironmentParameters.SecondaryColor; int BrushWidth = (int)EnvironmentParameters.BrushWidth; ColorBgra CurrentPixel; int Amount1 = 5; //[1,10]CountOfColumns int Amount2 = 5; //[1,10]CountOfRows int Amount3 = 50; //[0,50]Shifting(pixels) int Amount4 = 10; //[0,100]Fluctuation(%) int Amount5 = 0; //[0,359]MaxAngle(degrees) int n = Amount1; int m = Amount2; int shift = Amount3; double a = (selection.Right - selection.Left) / n; double b = (selection.Bottom - selection.Top) / m; double dFluct = (double)Amount4 / 100.0 * 0.95; double dAngle = (double)Amount5 / 360.0 * 3.1415926535897932384626433832795; int CenterN = (int)Math.Floor(n / 2.0); int CenterM = (int)Math.Floor(m / 2.0); double tempX, tempY; double tempCenterX, tempCenterY; double tempAngle; double tempCos, tempSin; double tempShiftX, tempShiftY; bool bGotcha; Random rand = new Random(); //Creating a matrix splitting the initial picture, [,,0] - x, [,,1] - y double[, ,] MatNet = new double[m + 1, n + 1, 2]; MatNet[0, 0, 0] = selection.Left; MatNet[0, 0, 1] = selection.Top; MatNet[m, 0, 0] = selection.Left; MatNet[m, 0, 1] = selection.Bottom; MatNet[0, n, 0] = selection.Right; MatNet[0, n, 1] = selection.Top; MatNet[m, n, 0] = selection.Right; MatNet[m, n, 1] = selection.Bottom; for (int j = 1; j < n; j++) { MatNet[0, j, 0] = selection.Left + a * ((double)j + dFluct * (rand.NextDouble() - 0.5)); MatNet[0, j, 1] = selection.Top; MatNet[m, j, 0] = selection.Left + a * ((double)j + dFluct * (rand.NextDouble() - 0.5)); MatNet[m, j, 1] = selection.Bottom; } for (int i = 1; i < m; i++) { MatNet[i, 0, 0] = selection.Left; MatNet[i, 0, 1] = selection.Top + b * ((double)i + dFluct * (rand.NextDouble() - 0.5)); MatNet[i, n, 0] = selection.Right; MatNet[i, n, 1] = selection.Top + b * ((double)i + dFluct * (rand.NextDouble() - 0.5)); for (int j = 1; j < n; j++) { MatNet[i, j, 0] = selection.Left + a * ((double)j + dFluct * (rand.NextDouble() - 0.5)); MatNet[i, j, 1] = selection.Top + b * ((double)i + dFluct * (rand.NextDouble() - 0.5)); } } //Creating a matrix of fragments of the shattered picture, [,,0,]..[,,3,] - vertexes, [,,4,] - rotating center, [,,,0] - x, [,,,1] - y, [,,5,] - Cos & Sin double[, , ,] MatFragments = new double[m, n, 7, 2]; // 01 - vertexes' position for (int i = 0; i < m; i++) // 23 { for (int j = 0; j < n; j++) { tempAngle = dAngle * rand.NextDouble(); tempCos = Math.Cos(tempAngle); tempSin = Math.Sin(tempAngle); tempShiftX = shift * (j - CenterN); //how much we should move the fragment tempShiftY = shift * (i - CenterM); tempCenterX = (double)selection.Left + a * ((double)j + 0.5); //a (rotating) center of the fragment tempCenterY = (double)selection.Top + b * ((double)i + 0.5); tempX = MatNet[i, j, 0] - tempCenterX; tempY = MatNet[i, j, 1] - tempCenterY; MatFragments[i, j, 0, 0] = tempX * tempCos - tempY * tempSin + tempCenterX + tempShiftX; //rotating and moving MatFragments[i, j, 0, 1] = tempY * tempCos + tempX * tempSin + tempCenterY + tempShiftY; tempX = MatNet[i, j + 1, 0] - tempCenterX; tempY = MatNet[i, j + 1, 1] - tempCenterY; MatFragments[i, j, 1, 0] = tempX * tempCos - tempY * tempSin + tempCenterX + tempShiftX; MatFragments[i, j, 1, 1] = tempY * tempCos + tempX * tempSin + tempCenterY + tempShiftY; tempX = MatNet[i + 1, j, 0] - tempCenterX; tempY = MatNet[i + 1, j, 1] - tempCenterY; MatFragments[i, j, 2, 0] = tempX * tempCos - tempY * tempSin + tempCenterX + tempShiftX; MatFragments[i, j, 2, 1] = tempY * tempCos + tempX * tempSin + tempCenterY + tempShiftY; tempX = MatNet[i + 1, j + 1, 0] - tempCenterX; tempY = MatNet[i + 1, j + 1, 1] - tempCenterY; MatFragments[i, j, 3, 0] = tempX * tempCos - tempY * tempSin + tempCenterX + tempShiftX; MatFragments[i, j, 3, 1] = tempY * tempCos + tempX * tempSin + tempCenterY + tempShiftY; MatFragments[i, j, 4, 0] = tempCenterX; MatFragments[i, j, 4, 1] = tempCenterY; MatFragments[i, j, 5, 0] = tempCos; MatFragments[i, j, 5, 1] = tempSin; MatFragments[i, j, 6, 0] = tempShiftX; MatFragments[i, j, 6, 1] = tempShiftY; } } for (int L = startIndex; L < startIndex + length; ++L) { Rectangle rect = rois[L]; for (int y = rect.Top; y < rect.Bottom; ++y) { for (int x = rect.Left; x < rect.Right; ++x) { CurrentPixel = srcArgs.Surface[x, y]; bGotcha = false; for (int i = 0; i < m; i++) { for (int j = 0; j < n; j++) { //if (x,y) is inside the fragment (i,j) we should restore a colour of the pixel (x,y) if (PointInQuadrilateral((double)x + 0.5, (double)y + 0.5, MatFragments[i, j, 0, 0], MatFragments[i, j, 0, 1], MatFragments[i, j, 1, 0], MatFragments[i, j, 1, 1], MatFragments[i, j, 2, 0], MatFragments[i, j, 2, 1], MatFragments[i, j, 3, 0], MatFragments[i, j, 3, 1])) { tempX = (double)x - MatFragments[i, j, 6, 0] - MatFragments[i, j, 4, 0]; tempY = (double)y - MatFragments[i, j, 6, 1] - MatFragments[i, j, 4, 1]; tempX = tempX * MatFragments[i, j, 5, 0] + tempY * MatFragments[i, j, 5, 1] + MatFragments[i, j, 4, 0]; tempY = tempY * MatFragments[i, j, 5, 0] - tempX * MatFragments[i, j, 5, 1] + MatFragments[i, j, 4, 1]; CurrentPixel = Interpolate(srcArgs.Surface, selection, tempX - 0.5, tempY - 0.5); dstArgs.Surface[x, y] = CurrentPixel; bGotcha = true; i = m; j = n; } } } //if (x,y) is beyond all fragments we should make the pixel (x,y) transparent if (!bGotcha) { CurrentPixel.R = (byte)PrimaryColor.R; CurrentPixel.G = (byte)PrimaryColor.G; CurrentPixel.B = (byte)PrimaryColor.B; CurrentPixel.A = 10; dstArgs.Surface[x, y] = CurrentPixel; } } } } }
  8. 2 pyrochild. I don't know how to open Error window in Visual Studio. I'd appreciate if you reveal that =) Ok, I've noticed this in the topic that EER had linked. public EffectPlugin() //: base(EffectPlugin.StaticName, EffectPlugin.StaticIcon, EffectPlugin.StaticSubMenuName, true) // Obsolete //: base(EffectPlugin.StaticName, EffectPlugin.StaticIcon, EffectPlugin.StaticSubMenuName, EffectFlags.Configurable | EffectFlags.SingleThreaded) : base(EffectPlugin.StaticName, EffectPlugin.StaticIcon, EffectPlugin.StaticSubMenuName, EffectFlags.Configurable) { } And the template has been built finally. Awesome! Two questions. Can anybody fix that template? The template seems to be very handy. And I don't think it would take a bunch of time to replace a few strings of code and save poor newbies from their brains crashed =) Is it possible to work with the template in CodeGear RAD Studio? I tried to check it but I didn't find the way to open the template there.
  9. I've encountered a error during a compilation. (MS Visual Studio 2005) 1. I deleted PdnLib reference and added PaintDotNet.Core. Then I tried to build and ------ Build started: Project: EffectsPluginTemplate2, Configuration: Debug Any CPU ------ C:\Windows\Microsoft.NET\Framework\v2.0.50727\Csc.exe /noconfig /nowarn:1701,1702 /errorreport:prompt /warn:4 /define:DEBUG;TRACE /reference:"..\..\..\..\..\..\..\Program Files\Paint.NET\PaintDotNet.Core.dll" /reference:"..\..\..\..\..\..\..\Program Files\Paint.NET\PaintDotNet.Effects.dll" /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.dll /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Drawing.dll /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Windows.Forms.dll /debug+ /debug:full /optimize- /out:obj\Debug\EffectsPluginTemplate2.dll /resource:obj\Debug\EffectsPluginTemplate2.EffectPluginConfigDialog.resources /resource:obj\Debug\EffectsPluginTemplate2.EffectPluginIcon.png /target:library EffectPluginToken.cs EffectPlugin.cs EffectPluginConfigDialog.cs Properties\AssemblyInfo.cs C:\Users\Yara\Documents\Visual Studio 2005\Projects\EffectsPluginTemplate2\EffectsPluginTemplate2\EffectPluginConfigDialog.cs(12,18): error CS0012: The type 'PaintDotNet.Threading.IDispatcherObject' is defined in an assembly that is not referenced. You must add a reference to assembly 'PaintDotNet.Base, Version=3.58.4081.24574, Culture=neutral, PublicKeyToken=null'. c:\Program Files\Paint.NET\PaintDotNet.Core.dll: (Related file) c:\Program Files\Paint.NET\PaintDotNet.Effects.dll: (Related file) Compile complete -- 1 errors, 0 warnings ========== Build: 0 succeeded or up-to-date, 1 failed, 0 skipped ========== 2. I added PaintDotNetBase reference and ------ Build started: Project: EffectsPluginTemplate2, Configuration: Debug Any CPU ------ C:\Windows\Microsoft.NET\Framework\v2.0.50727\Csc.exe /noconfig /nowarn:1701,1702 /errorreport:prompt /warn:4 /define:DEBUG;TRACE /reference:"..\..\..\..\..\..\..\Program Files\Paint.NET\PaintDotNet.Base.dll" /reference:"..\..\..\..\..\..\..\Program Files\Paint.NET\PaintDotNet.Core.dll" /reference:"..\..\..\..\..\..\..\Program Files\Paint.NET\PaintDotNet.Effects.dll" /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.dll /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Drawing.dll /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Windows.Forms.dll /debug+ /debug:full /optimize- /out:obj\Debug\EffectsPluginTemplate2.dll /resource:obj\Debug\EffectsPluginTemplate2.EffectPluginConfigDialog.resources /resource:obj\Debug\EffectsPluginTemplate2.EffectPluginIcon.png /target:library EffectPluginToken.cs EffectPlugin.cs EffectPluginConfigDialog.cs Properties\AssemblyInfo.cs C:\Users\Yara\Documents\Visual Studio 2005\Projects\EffectsPluginTemplate2\EffectsPluginTemplate2\EffectPlugin.cs(37,16): error CS0619: 'PaintDotNet.Effects.Effect.Effect(string, System.Drawing.Image, string, bool)' is obsolete: '' Compile complete -- 1 errors, 0 warnings ========== Build: 0 succeeded or up-to-date, 1 failed, 0 skipped ========== Blah. I miss Pascal so much.
  10. And after less than a month I've returned to my plugin =) Ok, I've found out that teh BUG is caused by ROI. So Eer, you was right. Rick, your post seems to be very helpful but there is a problem - no function OnSetRenderInfo() nor OnRender() in my program exist. I use CodeLab, and there is Render function only. Is it possible to create a piece of code called like OnSetRenderInfo() and another called like OnRender() (I think Render function works that way)? If it's impossible to do that in CodeLab please give me a link to a guide 'how to write Paint.NET plugins with C' or something like this.
  11. Thank you for an answer. I'm not really good at ROI. Is an entire program called when a new ROI is rendered or Render function only? In the second case all should work well.
  12. Some extra information. For short I'll call my problem teh BUG. Function Interpolate seems to be working well. Even if it's bugged it shouldn't relate to teh BUG. Function PointInQuadrilateral was written by myself so I thought the error is there. But I've tested it a lot and it seems to be working too. But I'm still not sure cause a bug in the function can cause teh BUG. I use 2 matrices - MatNet and MatFragments - and they could have some errors. But it shouldn't cause such a teh BUG. If vertexes were simply messed my plugin would render messed quadrilaterals. But it renders a total **** (teh BUG), not quadrilaterals at all. So... I'm stunned. It must be sorta a type conversion or overflow mistake but I can't find it.
  13. I'm coding my new (and actually first) Paint.NET plugin now and I can't solve a trouble. I've been trying for almost a day but this is a hard nut to crack. I have no idea why it happens. I thought I had eliminated all possible causes but this error is still here. As I'm new with CodeLab and C# I think it's relative to some compiler rule which I don't know. An idea of my plugin is simple. It splits an image to a few pieces and then move them aside. I use a matrix to keep vertexes of splitting. It works perfectly there. But if I add 'fluctuations' to change fragments (from rectangle to arbitrary quadrilaterals) Paint.NET renders a strange thing. I attached a piece of code. It's only a part of my plugin but it shows the error well. I'd really appreciate any ideas why the plugin works incorrectly. [The new code is placed below] Shatter.zip
×
×
  • Create New...