Jump to content

Unfinished plugins


Recommended Posts

This is my finished Align plugin. I will not post it on the Plugins - Publishing ONLY! thread because there is already Kris Vandermotten's, which is extremely fast even on very large canvases.

Thank you very much to MJW who helped me a lot. I learned a lot from him.

 

The UI:
aO4vULI.png

 

And here is the dll file:

 

►  Align.zip   ◄

  • Like 4
  • Upvote 2
Link to comment
Share on other sites

The UI looks great xod. You've made an excellent job of it. Its a great shame you're not releasing it more widely.

Link to comment
Share on other sites

The UI is very well done. I think you should release it. Just provide a link to Kris Vandermotten's alignment plugins, and explain that yours is an all-in-one version. One thing though: The version I have is in the top-level Effect menu. I think it should be in the Object Menu. I assume Kris Vandermotten's are in their own menu to keep them together, and because there are so many, to avoid cluttering the Object menu. Perhaps the name should be changed to "Align Object".

Link to comment
Share on other sites

Thank you all.

Actually I deliberately left it in the top-level Effect menu because I use it very often and I want it to be immediately visible.
If, however, it is absolutely necessary, I will change the place in the Object Menu.

 

I would also like to point out that the UI may appear slightly different on computers with default display settings.
I use a customized scaling factor of 123%.
I also modified WindowsMetrics to make the text larger by using a small utility called SystemFontSizeChanger.
I'm at the age I don't see so well.

Link to comment
Share on other sites

Thank you xod for an excellent plugin. I agree with EER and MJW that you should release it in the plugin forum with it's own topic.

I also agree with MJW regarding placing the plugin in a submenu. It is not "absolutely necessary" like you say, it's just better housekeeping IMO. I'll let you keep your own copy in the parent Effect menu because I like you  :) 

 

  • Like 2

Xkds4Lh.png

Link to comment
Share on other sites

Hi,

 

Working on new pluging, need some help/suggestion:

 

I want to add this  on the UI

//--------------------------------------------------------
// list of settings for each FX  
// (n is number from a1 to a7 and b1 to b7)
// Each effect (a) has its 'symetric' effect (b) 
//--------------------------------------------------------
// Fn  = Type of FX : 0=none, 1=flaRe ʘ, 2=flaKe *, 3=hexa ◊
// Dn  = distance (-/+) from the center of the image
// In  = internal diameter of the FX
// En  = external diameter of the FX
// Rn  = quantity of rays for flake/Inner circle steps for flare
// An  = invert the intensity (in to out / out to in)
// Cn  = grey level (0-255).
//--------------------------------------------------------
//--------------------------------------------------------
int Fa1 = 1; int Da1 = 490;  int Ia1 = 0;  int Ea1 = 80;  int Ra1 = 32; bool Aa1 = true;  int Ca1 = 80;
int Fa2 = 2; int Da2 = 415;  int Ia2 = 0;  int Ea2 = 460; int Ra2 = 32; bool Aa2 = false; int Ca2 = 255;
int Fa3 = 1; int Da3 = 415;  int Ia3 = 90; int Ea3 = 115; int Ra3 = 12; bool Aa3 = false; int Ca3 = 240;
int Fa4 = 3; int Da4 = 200;  int Ia4 = 0;  int Ea4 = 134; int Ra4 = 12; bool Aa4 = true;  int Ca4 = 100;
int Fa5 = 3; int Da5 = 150;  int Ia5 = 0;  int Ea5 = 70;  int Ra5 = 12; bool Aa5 = true;  int Ca5 = 200;
int Fa6 = 3; int Da6 = 60;   int Ia6 = 0;  int Ea6 = 48;  int Ra6 = 24; bool Aa6 = true;  int Ca6 = 180;
int Fa7 = 1; int Da7 = 1;    int Ia7 = 2;  int Ea7 = 4;   int Ra7 = 9;  bool Aa7 = false; int Ca7 = 255;

int Fb7 = 1; int Db7 = -100; int Ib7 = 0;  int Eb7 = 10;  int Rb7 = 9;  bool Ab7 = true;  int Cb7 = 200;
int Fb6 = 3; int Db6 = -240; int Ib6 = 0;  int Eb6 = 110; int Rb6 = 9;  bool Ab6 = false; int Cb6 = 80;
int Fb5 = 3; int Db5 = -266; int Ib5 = 0;  int Eb5 = 70;  int Rb5 = 12; bool Ab5 = true;  int Cb5 = 160;
int Fb4 = 1; int Db4 = -330; int Ib4 = 0;  int Eb4 = 40;  int Rb4 = 9;  bool Ab4 = true;  int Cb4 = 120;
int Fb3 = 1; int Db3 = -440; int Ib3 = 0;  int Eb3 = 240; int Rb3 = 12; bool Ab3 = true;  int Cb3 = 160;
int Fb2 = 2; int Db2 = 415;  int Ib2 = 0;  int Eb2 = 350; int Rb2 = 48; bool Ab2 = false; int Cb2 = 255;
int Fb1 = 2; int Db1 = 415;  int Ib1 = 0;  int Eb1 = 170; int Rb1 = 13; bool Ab1 = false; int Cb1 = 255;

98 elements to handle, this is not possible with codelab

 

Spoiler

Full code


// Name:Lens Flare
// Submenu:Render
// Author:MadJik (Jean-Claude JAY)
// Title:Lens Flare
// Version:0.54
// Desc:Lens Flare with flakes and flares
// Keywords:lens flare|flake|render
// URL: http://forums.getpaint.net/index.php?showtopic=7186

#region UICode
IntSliderControl Amount1 = 24;  // [-500,500] Distance factor
IntSliderControl Amount2 = 40; // [1,200] Radius factor
IntSliderControl Amount3 = 255; // [0,255] FlaKe * Intensity factor
IntSliderControl Amount4 = 30; // [0,255] FlaRe ʘ Intensity factor
IntSliderControl Amount5 = 4; // [0,200] FlaKe * width of ray
IntSliderControl Amount6 = 2; // [-100,100] FlaRe ʘ width adjustment of circle
IntSliderControl Amount7 = 10; // [0,100] Blur
#endregion

// Shared variables
//--------------------------------------------------------
// list of settings for each FX  
// (n is number from a1 to a7 and b1 to b7)
// Each effect (a) has its 'symetric' effect (b) 
//--------------------------------------------------------
// Fn  = Type of FX : 0=none, 1=flaRe ʘ, 2=flaKe *, 3=hexa ◊
// Dn  = distance (-/+) from the center of the image
// In  = internal diameter of the FX
// En  = external diameter of the FX
// Rn  = quantity of rays for flake/Inner circle steps for flare
// An  = invert the intensity (in to out / out to in)
// Cn  = grey level (0-255).
//--------------------------------------------------------
//--------------------------------------------------------
int Fa1 = 1; int Da1 = 490;  int Ia1 = 0;  int Ea1 = 80;  int Ra1 = 32; bool Aa1 = true;  int Ca1 = 80;
int Fa2 = 2; int Da2 = 415;  int Ia2 = 0;  int Ea2 = 460; int Ra2 = 32; bool Aa2 = false; int Ca2 = 255;
int Fa3 = 1; int Da3 = 415;  int Ia3 = 90; int Ea3 = 115; int Ra3 = 12; bool Aa3 = false; int Ca3 = 240;
int Fa4 = 3; int Da4 = 200;  int Ia4 = 0;  int Ea4 = 134; int Ra4 = 12; bool Aa4 = true;  int Ca4 = 100;
int Fa5 = 3; int Da5 = 150;  int Ia5 = 0;  int Ea5 = 70;  int Ra5 = 12; bool Aa5 = true;  int Ca5 = 200;
int Fa6 = 3; int Da6 = 60;   int Ia6 = 0;  int Ea6 = 48;  int Ra6 = 24; bool Aa6 = true;  int Ca6 = 180;
int Fa7 = 1; int Da7 = 1;    int Ia7 = 2;  int Ea7 = 4;   int Ra7 = 9;  bool Aa7 = false; int Ca7 = 255;

int Fb7 = 1; int Db7 = -100; int Ib7 = 0;  int Eb7 = 10;  int Rb7 = 9;  bool Ab7 = true;  int Cb7 = 200;
int Fb6 = 3; int Db6 = -240; int Ib6 = 0;  int Eb6 = 110; int Rb6 = 9;  bool Ab6 = false; int Cb6 = 80;
int Fb5 = 3; int Db5 = -266; int Ib5 = 0;  int Eb5 = 70;  int Rb5 = 12; bool Ab5 = true;  int Cb5 = 160;
int Fb4 = 1; int Db4 = -330; int Ib4 = 0;  int Eb4 = 40;  int Rb4 = 9;  bool Ab4 = true;  int Cb4 = 120;
int Fb3 = 1; int Db3 = -440; int Ib3 = 0;  int Eb3 = 240; int Rb3 = 12; bool Ab3 = true;  int Cb3 = 160;
int Fb2 = 2; int Db2 = 415;  int Ib2 = 0;  int Eb2 = 350; int Rb2 = 48; bool Ab2 = false; int Cb2 = 255;
int Fb1 = 2; int Db1 = 415;  int Ib1 = 0;  int Eb1 = 170; int Rb1 = 13; bool Ab1 = false; int Cb1 = 255;

int ProcessStep = 0;
int amount1 = -1;
int amount2 = -1;
int amount3 = -1;
int amount4 = -1;
int amount5 = -1;
int amount6 = -1;
int amount7 = -1;
int lightx = 100, lighty = 100, lightw = 0;
float vx = 0, vy = 0, cx = 0, cy = 0, ciFR = 0, ciFK = 0;
int sL,sT,sR,sB;
    
void Render(Surface dst, Surface src, Rectangle rect)
{
  Rectangle selection = EnvironmentParameters.GetSelection(src.Bounds).GetBoundsInt();
  // Test if setting has changed
  if (Amount1 != amount1) { amount1 = Amount1; ProcessStep = 0; }
  if (Amount2 != amount2) { amount2 = Amount2; ProcessStep = 0; }
  if (Amount3 != amount3) { amount3 = Amount3; ProcessStep = 0; }
  if (Amount4 != amount4) { amount4 = Amount4; ProcessStep = 0; }
  if (Amount5 != amount5) { amount5 = Amount5; ProcessStep = 0; }
  if (Amount6 != amount6) { amount6 = Amount6; ProcessStep = 0; }
  if (Amount7 != amount7) { amount7 = Amount7; ProcessStep = 0; }

  // Image center and borders
  sL = selection.Left;
  sT = selection.Top;
  sR = selection.Right;
  sB = selection.Bottom;
  cx = ((sR - sL) / 2) + sL;
  cy = ((sB - sT) / 2) + sT;
  ciFK = (float)amount3 / 100f;
  ciFR = (float)amount4 / 100f;
  if (ProcessStep == 0)
  {
    // Picture analyse to find the lightest pixel closest to color FFFFFF (white)
    // and backup original image
    for (int y = selection.Top; y < selection.Bottom; y++)
    {
      for (int x = selection.Left; x < selection.Right; x++)
      {
        dst[x, y] = src[x, y];
        ColorBgra col = src[x, y];
        int w1 = col.B + col.G + col.R + col.A;
        if (w1 > lightw)
        {
          lightx = x;
          lighty = y;
          lightw = w1;
        }
      }
    }
    ProcessStep = 1;
  }

  if (ProcessStep == 1)
  {
    // Light direction
    vx = (float)(lightx - cx);
    vy = (float)(lighty - cy);

    // Draw the flaRes/flaKes
    //DrawFlaRe(dst, int distance, int radiusInt, int radiusExt, bool Invert, int ColorVal, int verticies);
    //DrawFlaKe(dst, int distance, int radiusInt, int radiusExt, bool Invert, int ColorVal, int verticies);
    //DrawFHexa(dst, int distance, int radiusInt, int radiusExt, bool Invert, int ColorVal, int verticies);
    if (Fa1 == 1) DrawFlaRe(dst, Da1, Ia1, Ea1, Aa1, Ca1, Ra1);
    else if (Fa1 == 2) DrawFlaKe(dst, Da1, Ia1, Ea1, Aa1, Ca1, Ra1);
    else if (Fa1 == 3) DrawFHexa(dst, Da1, Ia1, Ea1, Aa1, Ca1, Ra1);
    
    if (Fa2 == 1) DrawFlaRe(dst, Da2, Ia2, Ea2, Aa2, Ca2, Ra2);
    else if (Fa2 == 2) DrawFlaKe(dst, Da2, Ia2, Ea2, Aa2, Ca2, Ra2);
    else if (Fa2 == 3) DrawFHexa(dst, Da2, Ia2, Ea2, Aa2, Ca2, Ra2);
    
    if (Fa3 == 1) DrawFlaRe(dst, Da3, Ia3, Ea3, Aa3, Ca3, Ra3);
    else if (Fa3 == 2) DrawFlaKe(dst, Da3, Ia3, Ea3, Aa3, Ca3, Ra3);
    else if (Fa3 == 3) DrawFHexa(dst, Da3, Ia3, Ea3, Aa3, Ca3, Ra3);

    if (Fa4 == 1) DrawFlaRe(dst, Da4, Ia4, Ea4, Aa4, Ca4, Ra4);
    else if (Fa4 == 2) DrawFlaKe(dst, Da4, Ia4, Ea4, Aa4, Ca4, Ra4);
    else if (Fa4 == 3) DrawFHexa(dst, Da4, Ia4, Ea4, Aa4, Ca4, Ra4);

    if (Fa5 == 1) DrawFlaRe(dst, Da5, Ia5, Ea5, Aa5, Ca5, Ra5);
    else if (Fa5 == 2) DrawFlaKe(dst, Da5, Ia5, Ea5, Aa5, Ca5, Ra5);
    else if (Fa5 == 3) DrawFHexa(dst, Da5, Ia5, Ea5, Aa5, Ca5, Ra5);

    if (Fa6 == 1) DrawFlaRe(dst, Da6, Ia6, Ea6, Aa6, Ca6, Ra6);
    else if (Fa6 == 2) DrawFlaKe(dst, Da6, Ia6, Ea6, Aa6, Ca6, Ra6);
    else if (Fa6 == 3) DrawFHexa(dst, Da6, Ia6, Ea6, Aa6, Ca6, Ra6);

    if (Fa7 == 1) DrawFlaRe(dst, Da7, Ia7, Ea7, Aa7, Ca7, Ra7);
    else if (Fa7 == 2) DrawFlaKe(dst, Da7, Ia7, Ea7, Aa7, Ca7, Ra7);
    else if (Fa7 == 3) DrawFHexa(dst, Da7, Ia7, Ea7, Aa7, Ca7, Ra7);

    if (Fb7 == 1) DrawFlaRe(dst, Db7, Ib7, Eb7, Ab7, Cb7, Rb7);
    else if (Fb7 == 2) DrawFlaKe(dst, Db7, Ib7, Eb7, Ab7, Cb7, Rb7);
    else if (Fb7 == 3) DrawFHexa(dst, Db7, Ib7, Eb7, Ab7, Cb7, Rb7);

    if (Fb6 == 1) DrawFlaRe(dst, Db6, Ib6, Eb6, Ab6, Cb6, Rb6);
    else if (Fb6 == 2) DrawFlaKe(dst, Db6, Ib6, Eb6, Ab6, Cb6, Rb6);
    else if (Fb6 == 3) DrawFHexa(dst, Db6, Ib6, Eb6, Ab6, Cb6, Rb6);

    if (Fb5 == 1) DrawFlaRe(dst, Db5, Ib5, Eb5, Ab5, Cb5, Rb5);
    else if (Fb5 == 2) DrawFlaKe(dst, Db5, Ib5, Eb5, Ab5, Cb5, Rb5);
    else if (Fb5 == 3) DrawFHexa(dst, Db5, Ib5, Eb5, Ab5, Cb5, Rb5);

    if (Fb4 == 1) DrawFlaRe(dst, Db4, Ib4, Eb4, Ab4, Cb4, Rb4);
    else if (Fb4 == 2) DrawFlaKe(dst, Db4, Ib4, Eb4, Ab4, Cb4, Rb4);
    else if (Fb4 == 3) DrawFHexa(dst, Db4, Ib4, Eb4, Ab4, Cb4, Rb4);

    if (Fb3 == 1) DrawFlaRe(dst, Db3, Ib3, Eb3, Ab3, Cb3, Rb3);
    else if (Fb3 == 2) DrawFlaKe(dst, Db3, Ib3, Eb3, Ab3, Cb3, Rb3);
    else if (Fb3 == 3) DrawFHexa(dst, Db3, Ib3, Eb3, Ab3, Cb3, Rb3);

    if (Fb2 == 1) DrawFlaRe(dst, Db2, Ib2, Eb2, Ab2, Cb2, Rb2);
    else if (Fb2 == 2) DrawFlaKe(dst, Db2, Ib2, Eb2, Ab2, Cb2, Rb2);
    else if (Fb2 == 3) DrawFHexa(dst, Db2, Ib2, Eb2, Ab2, Cb2, Rb2);

    if (Fb1 == 1) DrawFlaRe(dst, Db1, Ib1, Eb1, Ab1, Cb1, Rb1);
    else if (Fb1 == 2) DrawFlaKe(dst, Db1, Ib1, Eb1, Ab1, Cb1, Rb1);
    else if (Fb1 == 3) DrawFHexa(dst, Db1, Ib1, Eb1, Ab1, Cb1, Rb1);

    ProcessStep = 2;
  }
  // Setup for calling the Gaussian Blur effect
  if (Amount7 > 0)
  {
    GaussianBlurEffect blurEffect = new GaussianBlurEffect();
    PropertyCollection blurProps = blurEffect.CreatePropertyCollection();
    PropertyBasedEffectConfigToken BlurParameters = new PropertyBasedEffectConfigToken(blurProps);
    BlurParameters.SetPropertyValue(GaussianBlurEffect.PropertyNames.Radius, Amount7);
    blurEffect.SetRenderInfo(BlurParameters, new RenderArgs(dst), new RenderArgs(dst));
    // Call the Gaussian Blur function
    blurEffect.Render(new Rectangle[1] {rect},0,1);
    ProcessStep = 3;
  }
}

//--------------------------------------------------------
private void DrawFlaKe(Surface dst, int distance, int radiusInt, int radiusExt, bool InvertIntensity, int ColorVal, int verticies)
{
  // calculate arc between FX
  float th = (float)(2.0f * Math.PI / verticies); 

  // calculate the center of the FX
  float fx = (float)(cx + (((float)distance / 100f) * vx) * amount1 /100f );
  float fy = (float)(cy + (((float)distance / 100f) * vy) * amount1 /100f );
  float Rext = (float)(radiusExt * amount2/100f);
  float Rint = (float)(radiusInt * amount2/100f);
  if (Rext <= 0) Rext = 1;
  if (Rext < Rint)
  {
    float Rtmp = Rint;
    Rint = Rext;
    Rext = Rtmp;
  }
  float RextGrd = Rext + 1;
  float RintGrd = Rint - 1;

  byte col = Int32Util.ClampToByte((int)(ColorVal * ciFK));
  ColorBgra ecol = Color.FromArgb(255, 0, 0, 0);
  ColorBgra icol = Color.FromArgb(255, col, col, col);
  if (InvertIntensity)
  {
      ColorBgra tmpcol = ecol;
      ecol = icol;
      icol = tmpcol;
  }
      
  Graphics g = new RenderArgs(dst).Graphics;
  g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;

  //need a thickness for the gradient
  float gap = (float)(amount5 / 10f);
  for (float P = (float)(-Math.PI); P <= Math.PI; P += th)
  {  
    // calculate cos and sin 1 time instead 12
    double cosp = Math.Cos(P);
    double sinp = Math.Sin(P);
    double cosgap = gap * sinp;
    double singap = gap * cosp;

    float exg = (float)(RextGrd * cosp + fx); 
    float eyg = (float)(RextGrd * sinp + fy); 
    float ixg = (float)(RintGrd * cosp + fx); 
    float iyg = (float)(RintGrd * sinp + fy); 

    float ex0 = (float)(Rext * cosp - cosgap + fx); 
    float ey0 = (float)(Rext * sinp + singap + fy); 
    float ex1 = (float)(Rext * cosp + cosgap + fx); 
    float ey1 = (float)(Rext * sinp - singap + fy); 
    float ix0 = (float)(Rint * cosp - cosgap + fx); 
    float iy0 = (float)(Rint * sinp + singap + fy); 
    float ix1 = (float)(Rint * cosp + cosgap + fx); 
    float iy1 = (float)(Rint * sinp - singap + fy); 
    // Create points that define the gradient.
    PointF pointg0 = new PointF(ixg, iyg);
    PointF pointg1 = new PointF(exg, eyg);
    // Create points that define a ray.
    PointF point0 = new PointF(ix0, iy0);
    PointF point1 = new PointF(ex0, ey0);
    PointF point2 = new PointF(ex1, ey1);
    PointF point3 = new PointF(ix1, iy1);
    PointF[] Piece = { point0, point3, point2, point1 };
    // Secured draw of the ray
    try{
    LinearGradientBrush myGBrush = new LinearGradientBrush(pointg0, pointg1, icol, ecol);
    g.FillPolygon(myGBrush, Piece);} catch { }
  }
}
//--------------------------------------------------------
private void DrawFlaRe(Surface dst, int distance, int radiusInt, int radiusExt, bool InvertIntensity, int ColorVal, int v)
{
  int verticies = v - 1;
  int x, y;
  float fx = (float)(cx + (((float)distance / 100f) * vx) * amount1 / 100f);
  float fy = (float)(cy + (((float)distance / 100f) * vy) * amount1 / 100f);

  float Rext = (radiusExt * (float)amount2/100f);
  float Rint = (radiusInt * (float)amount2/100f);
  if (Rext <= 0) Rext = 1;
  if (Rext < Rint)
  {
    float Rtmp = Rint;
    Rint = Rext;
    Rext = Rtmp;
  }
  if (Rext == Rint) Rint = Rext - 1;

  float IntensityStep = (float)ColorVal / verticies;
  float Intensity = IntensityStep;
    if (InvertIntensity)
  {
      Intensity = (float)ColorVal;
      IntensityStep = -IntensityStep;
  }

  Graphics g = new RenderArgs(dst).Graphics;
  g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
  byte col;
  SolidBrush myBrush;
  float s = (Rext - Rint) / verticies;
  int BrushWidth = (int)(s + s * amount6 / 10f);
  for (float rX = Rext; rX > Rint; rX -= s)
  {
    x = (int)(fx - rX);
    y = (int)(fy - rX);

    col = Int32Util.ClampToByte((int)(Intensity * ciFR));
    myBrush = new SolidBrush(Color.FromArgb(255, col, col, col));
    Pen myPen = new Pen(myBrush, BrushWidth);
    g.DrawEllipse(myPen, x, y, 2 * rX, 2 * rX);
    Intensity += IntensityStep;
  }
  if (Rint ==0)
  {
    col = Int32Util.ClampToByte((int)(Intensity * ciFR));
    myBrush = new SolidBrush(Color.FromArgb(255, col, col, col));
    g.FillEllipse(myBrush, fx - s / 2, fy -s / 2, s, s);
  }
}
//--------------------------------------------------------
private void DrawFHexa(Surface dst, int distance, int radiusInt, int radiusExt, bool InvertIntensity, int ColorVal, int v)
{
  int verticies = v - 1;
  int x, y;
  float fx = (float)(cx + (((float)distance / 100f) * vx) * amount1 / 100f);
  float fy = (float)(cy + (((float)distance / 100f) * vy) * amount1 / 100f);

  float Rext = (radiusExt * (float)amount2/100f);
  float Rint = (radiusInt * (float)amount2/100f);
  if (Rext <= 0) Rext = 1;
  if (Rext < Rint)
  {
    float Rtmp = Rint;
    Rint = Rext;
    Rext = Rtmp;
  }
  if (Rext == Rint) Rint = Rext - 1;

  float IntensityStep = (float)ColorVal / verticies;
  float Intensity = IntensityStep;
    if (InvertIntensity)
  {
      Intensity = (float)ColorVal;
      IntensityStep = -IntensityStep;
  }

  Graphics g = new RenderArgs(dst).Graphics;
  g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
  byte col;
  SolidBrush myBrush;
  float s = (Rext - Rint) / verticies;
  int BrushWidth = (int)(s + s * amount6 / 10f);
  for (float rX = Rext; rX > Rint; rX -= s)
  {
    col = Int32Util.ClampToByte((int)(Intensity * ciFR));
    myBrush = new SolidBrush(Color.FromArgb(255, col, col, col));
    Pen myPen = new Pen(myBrush, BrushWidth);
    PointF Point1 = new PointF(fx + rX * 1f, fy + rX * 0f);
    PointF Point2 = new PointF(fx + rX * 0.5f, fy + rX * 0.8660254f);
    PointF Point3 = new PointF(fx + rX * -0.5f, fy + rX * 0.8660254f);
    PointF Point4 = new PointF(fx + rX * -1f, fy + rX * 0f);
    PointF Point5 = new PointF(fx + rX * -0.5f, fy + rX * -0.8660254f);
    PointF Point6 = new PointF(fx + rX * 0.5f, fy + rX * -0.8660254f);
    PointF[] myPiece = { Point1, Point2, Point3, Point4, Point5, Point6 };
    g.DrawPolygon(myPen, myPiece);
    Intensity += IntensityStep;
  }
  if (Rint ==0)
  {
    col = Int32Util.ClampToByte((int)(Intensity * ciFR));
    myBrush = new SolidBrush(Color.FromArgb(255, col, col, col));
    g.FillEllipse(myBrush, fx - s / 2, fy -s / 2, s, s);
  }
}

 

 

I'm about to use Visual Studio. Any suggestion are welcome.

I'm also looking for routines to save/load the settings...

 

 

Link to comment
Share on other sites

5 hours ago, MadJik said:

I'm also looking for routines to save/load the settings...

 

In order to save and load the setting you would have to create the dialog using Windows Forms.

I posted an example of loading and saving XML settings in the following post (it is a Windows Forms version of @Red ochre's FurBlur plugin).

 

PdnSig.png

Plugin Pack | PSFilterPdn | Content Aware Fill | G'MICPaint Shop Pro Filetype | RAW Filetype | WebP Filetype

The small increase in performance you get coding in C++ over C# is hardly enough to offset the headache of coding in the C++ language. ~BoltBait

 

Link to comment
Share on other sites

  • 2 weeks later...
  • 2 weeks later...

When i try to save the file I just opened, it doesn't work (A generic error occurred in GDI+. ErrorCode: -2147467259)
When I try to save it with a different name, it works fine.
I think the png file has the path blocked because it's open.
But how can I close the path and save as the same name (overwrite)?

private void saveToolStripMenuItem_Click(object sender, EventArgs e)
        {
            using (Bitmap bmp = new Bitmap(pictureBox1.Width, pictureBox1.Height))
            {
                Graphics g = Graphics.FromImage(bmp);
                Rectangle rect = pictureBox1.RectangleToScreen(pictureBox1.ClientRectangle);
                g.CopyFromScreen(rect.Location, Point.Empty, pictureBox1.Size);
                g.Dispose();

                SaveFileDialog saveFile = new SaveFileDialog();
                saveFile.Filter = "PNG (*png)|*.png|JPEG (*jpg)|*.jpg|BMP (*bmp)|*.bmp|TIFF (*tiff)|*.tiff|All files (*png, *jpg, *bmp, *tiff)|*.png;*.jpg;*.bmp;*.tiff";
                if (saveFile.ShowDialog() == DialogResult.OK)
                    try
                    {
                        bmp.Save(saveFile.FileName);
                    }
                    catch
                    {
                        //I tried to create a new bitmap but it did not work
                        using (Bitmap newbmp = new Bitmap(bmp.Width, bmp.Height))
                        {
                            bmp.Dispose();
                            newbmp.Save(saveFile.FileName);
                        }
                    }
            }
        }

 

Link to comment
Share on other sites

Quote

Saving the image to the same file it was constructed from is not allowed and throws an exception.

ref: https://docs.microsoft.com/en-us/dotnet/api/system.drawing.image.save

 

 

I have not tried this, but maybe:

bmp.Clone().Save(saveFile.FileName);

 

(September 25th, 2023)  Sorry about any broken images in my posts. I am aware of the issue.

bp-sig.png
My Gallery  |  My Plugin Pack

Layman's Guide to CodeLab

Link to comment
Share on other sites

Thanks @toe_head2001 but I've solved the problem in the Load File method.

 

Spoiler

OpenFileDialog openfile = new OpenFileDialog();
            openfile.Filter = "PNG (*png)|*.png|JPEG (*jpg)|*.jpg|BMP (*bmp)|*.bmp|TIFF (*tiff)|*.tiff|All files (*png, *jpg, *bmp, *tiff)|*.png;*.jpg;*.bmp;*.tiff";
            if (openfile.ShowDialog() == DialogResult.OK)
            {
                if (pictureBox1.Image != null) pictureBox1.Image.Dispose();//release pictureBox and memory
                of = true;//openfile flag = true
                File = Image.FromFile(openfile.FileName);
                Text = string.Format("Filename - {0}", Path.GetFileName(openfile.FileName));
                Bitmap editableBmp = new Bitmap(File);
                pictureBox1.Image = editableBmp;
                File.Dispose();//release the file
                btnOK.Focus();
                return;
            }
            of = false;//DialogResult = Cancel -> opefile flag = false

 

 

Link to comment
Share on other sites

  • 1 month later...

@xod Do you meant Histograms?

This seems to be a bar graph generator (histogram) and definitly not a way to rework the histogram of colors in a picture.

 

In which way it is unfinished, what would you want to to add?

 

Why not use Excel or equivalent to handle all this? You still could save the graph as an image and rework it in paint.net.

 

 

 

 

Link to comment
Share on other sites

I was thinking of a 3D bar graph.

 

11 minutes ago, MadJik said:

Why not use Excel or equivalent to handle all this? You still could save the graph as an image and rework it in paint.net.

 

Well, that's the reason I abandoned it. 

Link to comment
Share on other sites

6 hours ago, xod said:

Hystograms is an unfinished plug-in. If someone is interested he can develop it.

 

I think it's pretty cool B)

Link to comment
Share on other sites

This is my Outlined text plugin. Is not working very well because of the approach.

 

Spoiler

// Name: Outlined text
// Submenu: Text Formations
// Author: xod
// Title: Outlined text
// Version: 1.0
// Desc:
// Keywords:
// URL:
// Help:

#region UICode
MultiLineTextboxControl Amount1 = "Test"; // [1,32767] Text
FontFamily Amount2 = new FontFamily("Arial"); // Font
IntSliderControl Amount3 = 72; // [2,400] Font size
ColorWheelControl Amount4 = ColorBgra.FromBgr(255,255,255); // [White] Font color
IntSliderControl Amount5 = 5; // [1,10] Outline size
ColorWheelControl Amount6 = ColorBgra.FromBgr(0,0,0); // [Black] Outline color
PanSliderControl Amount7 = Pair.Create(0.000,0.000); // Location
#endregion

void Render(Surface dst, Surface src, Rectangle rect)
{
    Rectangle sel = EnvironmentParameters.GetSelection(src.Bounds).GetBoundsInt();
    dst.CopySurface(src,rect.Location,rect);

    int adrX = (int)Math.Round(((Amount7.First + 1) / 2) * (sel.Right - sel.Left));
    int adrY = (int)Math.Round(((Amount7.Second + 1) / 2) * (sel.Bottom - sel.Top));

    String text = Amount1;
    FontFamily font = Amount2;
    int txtSize = Amount3;
    Color fontColor = Amount4;
    int outlineSize = Amount5;
    Color outlineColor = Amount6;
    byte opacity = 255;

    Graphics g = new RenderArgs(dst).Graphics;
    g.SmoothingMode = SmoothingMode.AntiAlias;
    g.TextRenderingHint = TextRenderingHint.AntiAlias;

    StringFormat format = new StringFormat();
    format.Alignment = StringAlignment.Center;
    format.LineAlignment = StringAlignment.Center;
    
    using (GraphicsPath path = new GraphicsPath())
    using (Pen outlinePen = new Pen(Color.FromArgb(opacity, outlineColor), outlineSize))
    using (SolidBrush myBrush = new SolidBrush(fontColor))
    {
        g.Clip = new Region(rect);
        FontFamily myFont;
        try
        {
            myFont = new FontFamily(font.Name);
        }
        catch
        {
            myFont = new FontFamily("Arial");
        }
        path.AddString(text, myFont, (int)FontStyle.Regular, g.DpiY * txtSize / 72, new PointF(adrX, adrY), format);
        g.DrawPath(outlinePen, path);
        g.FillPath(myBrush, path);
    }
}

 

 

Outlined text.zip

  • Like 1
Link to comment
Share on other sites

A bit more complex, but I think you could create the path in PreRender. That would require you dispose of it in an OnDispose routine instead of relying on a "using" block.

 

EDIT: I haven't tried this yet, so I don't know if there might be problems accessing path from multiple threads.

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.

×
×
  • Create New...