Jump to content

Keanny Ooi

Newbies
  • Posts

    9
  • Joined

  • Last visited

Everything posted by Keanny Ooi

  1. I would like it to work like a stamp tool that stamps the picture in place, with the anchor set in the middle. I would like the pic to be stored inside the plugin. It should also allow the picture to be exchanged with another one. Not sure if it is feasible or not? As for the MeasureString thing, thanks a lot! I sure will do my searching in the Microsoft docs before asking here!
  2. Thanks a lot! Here are more questions: 1. (was asked before but no one answered) 2. Here is a string of words. I would like it so that the unbolded text's location depends on how long the bolded text is. Let's say I changed the bolded text to this random meme. The word "there" should move to the right side a little bit because the meme word is longer than the word "Hello". If the bolded word is shorter, the unbolded text should move to the left a little bit. TL, DR: The spacing between the bolded word and the unbolded one remains the same. Is this possible? If so, how? -Keanny
  3. Thanks a lot! I feel like there should be a code reference for CodeLab, that way it can be easier for beginners. btw one more question, is it possible to change the alignment of the text while printing it? Example: you set the alignment to the right, text goes to the right as more text is added. you set the alignment to the left, text goes to the left as more text is added. you set the alignment to the middle, text goes to the middle as more text is added. -Keanny
  4. UPDATE: After some improvising using BoltBait's code, I finally did it! Thank you everyone for your help! Also quick question: Are paint.net plugins capable of inserting pictures into the canvas? Example: https://imgur.com/a/Y3AhvhK Here is a picture. Let's say i want to insert another picture into said picture, all within a press of a button. It should look like this after pressing the button: https://imgur.com/a/raFmwdY Is this possible? EDIT: @BoltBait, is it possible to print out bold text using the DrawString function? -Keanny
  5. No, I delete the UI stuff and basically it would automatically set the Gaussian blur to 70, and apply it to a fixed place. All in a press of a button. There are no constraints at all.
  6. For some reason i got this error message: System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt. at PaintDotNet.SystemLayer.PdnNativeMethods.x64.EffectKernel_GaussianBlur(PdnBitmapData& dstBitmap, PdnBitmapData& srcBitmap, Rectangle* pRois, Int32 roisLength, Int32 blurRadius) at PaintDotNet.SystemLayer.RenderingKernels.GaussianBlur(BitmapData dstBitmap, BitmapData srcBitmap, Rectangle[] rois, Int32 startIndex, Int32 length, Int32 blurRadius) in D:\src\pdn\src\SystemLayer\RenderingKernels.cs:line 521 at PaintDotNet.Effects.GaussianBlurEffect.OnRender(Rectangle[] rois, Int32 startIndex, Int32 length) in D:\src\pdn\src\Effects\GaussianBlurEffect.cs:line 141 at TDCEffect.TDCEffectPlugin.Render(Surface dst, Surface src, Rectangle rect) at TDCEffect.TDCEffectPlugin.OnRender(Rectangle[] rois, Int32 startIndex, Int32 length) at PaintDotNet.Effects.Effect`1.Render(EffectConfigToken parameters, RenderArgs dstArgs, RenderArgs srcArgs, Rectangle[] rois, Int32 startIndex, Int32 length) in D:\src\pdn\src\Effects\Effect`1.cs:line 99 at PaintDotNet.Effects.BackgroundEffectRenderer.RenderWithClipMask(Effect effect, EffectConfigToken token, RenderArgs dstArgs, RenderArgs srcArgs, RectInt32[] rois, Result`1 lazyClipMaskRenderer) in D:\src\pdn\src\PaintDotNet\Effects\BackgroundEffectRenderer.cs:line 193 at PaintDotNet.Effects.BackgroundEffectRenderer.RendererContext.RenderTile(EffectConfigToken token, Int32 tileIndex) in D:\src\pdn\src\PaintDotNet\Effects\BackgroundEffectRenderer.cs:line 173 at PaintDotNet.Effects.BackgroundEffectRenderer.RendererContext.RenderNextTile(EffectConfigToken token) in D:\src\pdn\src\PaintDotNet\Effects\BackgroundEffectRenderer.cs:line 165 at PaintDotNet.Effects.BackgroundEffectRenderer.ThreadFunction() in D:\src\pdn\src\PaintDotNet\Effects\BackgroundEffectRenderer.cs:line 283 --- End of inner exception stack trace --- at PaintDotNet.Effects.BackgroundEffectRenderer.DrainExceptions() in D:\src\pdn\src\PaintDotNet\Effects\BackgroundEffectRenderer.cs:line 458 at PaintDotNet.Menus.EffectMenuBase.DoEffect(Effect effect, EffectConfigToken token, Result`1 lazySelectionScans, Result`1 lazyRegionToRenderScans, Result`1 lazyClipMaskRenderer, Surface originalSurface, Exception& exception) in D:\src\pdn\src\PaintDotNet\Menus\EffectMenuBase.cs:line 0 This is causing the plugin to not work at all. Here is my modified script: // Setup for calling the Gaussian Blur effect GaussianBlurEffect gaussianblurEffect = new GaussianBlurEffect(); PropertyCollection gaussianblurProps; protected override void OnDispose(bool disposing) { if (disposing) { // Release any surfaces or effects you've created if (gaussianblurEffect != null) gaussianblurEffect.Dispose(); gaussianblurEffect = null; } base.OnDispose(disposing); } void PreRender(Surface dst, Surface src) { // Gaussian Blur gaussianblurEffect.EnvironmentParameters = EnvironmentParameters; gaussianblurProps = gaussianblurEffect.CreatePropertyCollection(); PropertyBasedEffectConfigToken gaussianblurParameters = new PropertyBasedEffectConfigToken(gaussianblurProps); gaussianblurParameters.SetPropertyValue(GaussianBlurEffect.PropertyNames.Radius, 70); gaussianblurEffect.SetRenderInfo(gaussianblurParameters, new RenderArgs(dst), new RenderArgs(src)); } void Render(Surface dst, Surface src, Rectangle rect) { dst.CopySurface(src, rect.Location, rect); Rectangle sel = EnvironmentParameters.GetSelection(src.Bounds).GetBoundsInt(); int sT = sel.Top; int sB = sel.Bottom; int sL = sel.Left; int sR = sel.Right; int x = 1064; int y = 96; Point left = new Point(sL, sT + x); Point rite = new Point(sR, sT + x); Point top = new Point(y + sL, sT); Point bot = new Point(y + sL, sB); int w = sR - sL; int h = left.Y - sT; Rectangle r1 = new Rectangle(0, 0, w, h); w = sR - top.X; h = sB - sT; Rectangle r2 = new Rectangle(top.X, 0, w, h);; // Now call the Gaussian Blur function from src surface to dst surface gaussianblurEffect.Render(new Rectangle[1] {r1},0,1); gaussianblurEffect.Render(new Rectangle[1] {r2},0,1); } Other than that, thanks for the code that you provided me!
  7. UPDATE: I figured out how to apply Gaussian blur of 70 to the entire image. Now I just have to narrow it down to that selected area. I'm thinking about trying to get the coordinates of every single pixel during pixel processing, how should I do that? (mock up) Example: if (CurrentPixel.Coordinates.X >= 1064 || CurrentPixel.Coordinates.Y <= 96) { // idk what im doing here // apply gaussian blur here } Is there such property for CurrentPixel? Thanks in advance. -Keanny
  8. Yes, that's what I meant. Sorry about that. First time posting here so I don't know which goes where.
  9. Hi there! I'm new to plugin coding and I would like to create a plugin that can blur a specific part of an image (not selected) just with a click of a button. Example: https://imgur.com/a/9LPCstX Here is a random image of a car. (file size too big so I had to resort to this) The selected area is exactly where I want to blur. What I want to do is that this specific area (it's ok if the selected area looks weird, I know how to break it up) is applied with Gaussian blur of 70 every time I press the button, regardless of whether or not that area is selected. It should look like this after pressing the button: https://imgur.com/a/899z9C2 Any help is much appreciated since I am just starting out. Thanks! -Keanny (P.S.: first post here)
×
×
  • Create New...