Red ochre

Members
  • Content Count

    2,494
  • Joined

  • Last visited

  • Days Won

    103

Everything posted by Red ochre

  1. It's in 'Evanolds' plug in pack, which is pinned in the plugins section. Once you've unzipped it and put it in the effects folder, it shows up under Effects/distorts/quadrilateral reshape. - I've used it when trying to unskew photos of real paintings that have been taken from an angle. Just had a look in my effects folder and I presume the effect is in EOeffects.dll, as I've got the effect but no .dll called quadrilateral reshape!
  2. I may have misunderstood but If you want to give the impression of rotating around the vertical axis, through the picture plane, then the "Quadrilateral reshape" plug in is very useful.
  3. I have problems with this too. I try to save before using it, as it can crash if the tolerance level is too broad. It probably doesn't actually crash, but life is too short to wait. It would be helpful to have some way of aborting it, once started, too avoid a near infinite hang, allowing you to reset the tolerance to something it can deal with.(2gb dualcore Vista)
  4. Thanks for the reply. Sorry, I still don't understand. I'm reading from the src into an array, then changing the values in the array (to avoid unwanted 'feedback'from refencing pixels that will be changed), then using these new values to write to the dst. At some stage in that process the plugin is deciding that a single 'line' pixel which is surrounded by 'background' pixels - isn't? (when I can see it is !). Surely if it wasn't writing to dst along the ROI borders, the image would have either solid horizontal lines or lines of the unaltered src image(colour)? The process does what it should inbetween these borders and on the borders still manages to 'write' the part-processed image - ie black and white. It just isn't changing it to what it should be from the array. Black or white (from true, true or false, false in the array) & red if added (false, true), cyan if removed (true, false). Anyway - thanks for the reply - If you can think of anyway round this or any plugins (with published code), which have overcome this problem, I'd be very grateful.
  5. I'm working on the attached plugin (which creates various types of ink outline). The problem I can't solve, is in the 'enhancements' section, where I am trying to remove isolated pixels and add in pixels to fill gaps. I'm doing this by 'looking' at the surrounding pixels - However, I think the rectangle of interest is stopping it seeing around the current pixel when it borders 2 ROIs. I am testing the plugin by marking line pixels that have been added in, red, and those removed, cyan. If you zoom right in on the attached image you will see where it's going wrong. I have tried the 'g.clip' code with no effect and really think I need someway of making it consider the whole whole image as 1 ROI to avoid this. Of course it could be due to something else. I would be grateful for any ideas on how to solve this. Please bear in mind that I'm very new to C# and this is very much a 'beta' version - it will need a lot of tidying up, but I need to sort this problem first. Many thanks By the way I think the answer to the question is using a method outside of the render loop - but haven't got back to this yet. /* =================================================== */ /* */ /* Advanced Beta Ink drawing.cs */ /* (c) 2011 Red Ochre (John Robbins) */ /* */ /* Description: produces various ink outlines */ /* */ /* ========================================== ======== */ // Name: Beta Complex ink drawing // Author: Red ochre (John Robbins) // Submenu: Advanced // URL: http://www.getpaint.net/redirect/plugins.html // Title: Complex ink drawing - 2011 Red Ochre #region UICode byte Amount1 = 0; // detection type|0.darker than blur|1.lighter than blur|2.both (blur)|3.darker by colour (blur)|4.edge detect|5.emboss|6.oil painting|7.relief int Amount2 = 5; // [1,100] blur radius - smoothness OR edge angle OR brush size int Amount3 = -100; // [-256,256] dark / bright threshold byte Amount4 = 0; // outline properties|primary colour|transparent|as original(src)|as detection type(dst)|src greys|dst greys|secondary colour byte Amount5 = 0; // background properties|secondary colour|transparent|as original(src)|as detection type(dst)|src greys|dst greys|primary colour int Amount6 = 765; // [0,765] background if tone above this int Amount7 = 0; // [0,765] background if tone below this byte Amount8 = 6; // enhancements|none|1....by 4|2..... by 8|3....by 20|4... by 36|5.link lines|6.thicken lines byte Amount9 = 1; // presets|normal|test mode (red = added pix. cyan = removed) #endregion void Render(Surface dst, Surface src, Rectangle rect) {// Graphics g = new RenderArgs(dst).Graphics; // this doesn't seem to work as ROI still causes problems // g.Clip = new Region(rect); // comment this code out if(Amount1 == 0 || Amount1 == 1 || Amount1 == 2 || Amount1 == 3){ // Call the Gaussian Blur effect GaussianBlurEffect blurEffect = new GaussianBlurEffect(); PropertyCollection bProps = blurEffect.CreatePropertyCollection(); PropertyBasedEffectConfigToken bParameters = new PropertyBasedEffectConfigToken(bProps); bParameters.SetPropertyValue(GaussianBlurEffect.PropertyNames.Radius, Amount2); blurEffect.SetRenderInfo(bParameters, new RenderArgs(dst), new RenderArgs(src)); blurEffect.Render(new Rectangle[1] {rect},0,1);} if(Amount1 == 4){ // Setup for calling the Edge Detect effect EdgeDetectEffect edgedetectEffect = new EdgeDetectEffect(); PropertyCollection edgeProps = edgedetectEffect.CreatePropertyCollection(); PropertyBasedEffectConfigToken EdgeParameters = new PropertyBasedEffectConfigToken(edgeProps); EdgeParameters.SetPropertyValue(EdgeDetectEffect.PropertyNames.Angle, (double)((50 - Amount2) * 1.8)); edgedetectEffect.SetRenderInfo(EdgeParameters, new RenderArgs(dst), new RenderArgs(src)); // Call the Edge Detect function edgedetectEffect.Render(new Rectangle[1] {rect},0,1);} if(Amount1 == 5){// Setup for calling the Emboss function EmbossEffect embossEffect = new EmbossEffect(); PropertyCollection eProps = embossEffect.CreatePropertyCollection(); PropertyBasedEffectConfigToken eParameters = new PropertyBasedEffectConfigToken(eProps); eParameters.SetPropertyValue(EmbossEffect.PropertyNames.Angle, (double)((50 - Amount2) * 1.8)); embossEffect.SetRenderInfo(eParameters, new RenderArgs(dst), new RenderArgs(src)); // Call the Emboss function embossEffect.Render(new Rectangle[1] {rect},0,1);} if(Amount1 == 6){// Setup for calling the Oil Painting effect OilPaintingEffect oilpaintEffect = new OilPaintingEffect(); PropertyCollection oilpaintProps = oilpaintEffect.CreatePropertyCollection(); PropertyBasedEffectConfigToken oilpaintParameters = new PropertyBasedEffectConfigToken(oilpaintProps); oilpaintParameters.SetPropertyValue(OilPaintingEffect.PropertyNames.BrushSize,(int) ((Amount2 * 8) / 100)); oilpaintParameters.SetPropertyValue(OilPaintingEffect.PropertyNames.Coarseness, 3); oilpaintEffect.SetRenderInfo(oilpaintParameters, new RenderArgs(dst), new RenderArgs(src)); // Call the Oil Painting function oilpaintEffect.Render(new Rectangle[1] {rect},0,1);} if(Amount1 == 7){// Setup for calling the Relief effect ReliefEffect reliefEffect = new ReliefEffect(); PropertyCollection reliefProps = reliefEffect.CreatePropertyCollection(); PropertyBasedEffectConfigToken ReliefParameters = new PropertyBasedEffectConfigToken(reliefProps); ReliefParameters.SetPropertyValue(ReliefEffect.PropertyNames.Angle, (double)((50 - Amount2) * 1.8)); reliefEffect.SetRenderInfo(ReliefParameters, new RenderArgs(dst), new RenderArgs(src)); // Call the Relief function reliefEffect.Render(new Rectangle[1] {rect},0,1);} ColorBgra PrimaryColor = (ColorBgra)EnvironmentParameters.PrimaryColor; ColorBgra SecondaryColor = (ColorBgra)EnvironmentParameters.SecondaryColor; ColorBgra cp; // current pixel ColorBgra dp; // destination pixel int B, G, R, A, dB, dG, dR, dA,td,ts,lb,lg,lr,la,bb,bg,br,ba,h,w,r; int th = Amount3; int th3 = Amount3/3; int H = rect.Bottom - rect.Top; int W = rect.Right - rect.Left; byte A8 = Amount8; bool[,,]v = new bool[W,H,2]; // hope this is ok. array W by H and true or false * 2 bool l = true; bool b = false; // l = outline = true; b = background = false for (int y = rect.Top; y < rect.Bottom; y++) // LOOP 1 analyze src and put result in array sval { for (int x = rect.Left; x < rect.Right; x++) { h = y - rect.Top; w = x - rect.Left; cp = src[x,y]; B = (int)cp.B; G = (int)cp.G; R = (int)cp.R; A = (int)cp.A; dp = dst[x,y]; dB = (int)dp.B; dG = (int)dp.G; dR = (int)dp.R; dA = (int)dp.A; td = dB + dG + dA;// destination - blurred, edge detected, embossed pixel ts = B + G + R;// source - unblurred pixel th3 = th / 3; if(Amount1 == 0 || Amount1 == 2 || Amount1 == 4 ||Amount1 == 5 ||Amount1 == 6 || Amount1 == 7 || Amount1 == 8) {if(ts < td + th && ts > Amount7 && ts <= Amount6){v[w,h,0] = l;} // if darker (line) then true else v[w,h,0] = b; } if(Amount1 == 1) {if(ts > td - th && ts > Amount7 && ts <= Amount6){v[w,h,0] = l;} // if lighter than blur by amount2 then also true else if (Amount1 == 1){ v[w,h,0] = b;} } if(Amount1 == 2) {if((ts < td + th || ts >= td - th) && ts > Amount7 && ts <= Amount6){v[w,h,0] = l;} // both, if darker (line) or lighter (background)then true else if (Amount1 == 2){ v[w,h,0] = b;} } if(Amount1 == 3) {if((B < dB + th3 || G < dG + th3 || R < dR + th3) && ts > Amount7 && ts <= Amount6){v[w,h,0] = l;} // darker by colour else if (Amount1 == 3){ v[w,h,0] = b;} } v[w,h,1] = v[w,h,0]; } } if(A8 > 0 ) {for (int y = rect.Top; y < rect.Bottom; y++) // LOOP 2 - changes sval entries remove single pixels { for (int x = rect.Left; x < rect.Right; x++) { h = y - rect.Top;w = x - rect.Left; if(h >= 1 && h < H-1) {if(w >= 1 && w < W-1) {if(A8 > 0 ) {if(v[w,h,0] == l && v[w - 1,h ,0] == b && // case 1 - by 4 v[w ,h - 1,0] == b && v[w ,h + 1,0] == b && v[w + 1,h ,0] == b ) {v[w,h,1] = b;}// if line surrounded by 4 background make background if(v[w,h,0] == b && v[w - 1,h ,0] == l && v[w ,h - 1,0] == l && v[w ,h + 1,0] == l && v[w + 1,h ,0] == l ) {v[w,h,1] = l;}}// if background surrounded by 4 line make line if(A8 > 1 ) {if(v[w,h,0] == l && v[w - 1,h - 1,0] == b && // case 2 - by 8 v[w - 1,h + 1,0] == b && v[w + 1,h - 1,0] == b && v[w + 1,h + 1,0] == b ) {v[w,h,1] = b;}// if line surrounded by 4 background make background if(v[w,h,0] == b && v[w - 1,h - 1 ,0] == l && v[w - 1,h + 1,0] == l && v[w + 1,h - 1,0] == l && v[w + 1,h + 1,0] == l ) {v[w,h,1] = l;}// if background surrounded by 4 line make line } } } if(h >= 2 && h < H - 2) {if(w >= 2 && w < W - 2) {if(A8 > 2) {if(v[w,h,0] == l && v[w - 2,h ,0] == b && // case 3 - 20. previous 8 checks & 12 pix perimeter check v[w - 2,h - 1,0] == b && v[w - 1,h - 2,0] == b && v[w ,h - 2,0] == b && v[w + 1,h - 2,0] == b && v[w + 2,h - 1,0] == b && v[w + 2,h ,0] == b && v[w + 2,h + 1,0] == b && v[w + 1,h + 2,0] == b && v[w ,h + 2,0] == b && v[w - 1,h + 2,0] == b && v[w - 2,h + 1,0] == b ) {v[w,h,1] = b;} // make background if isolated line pix if(v[w,h,0] == b && v[w - 2,h ,0] == l && // case 3 - same for sad lonely background pixies v[w - 2,h - 1,0] == l && v[w - 1,h - 2,0] == l && v[w ,h - 2,0] == l && v[w + 1,h - 2,0] == l && v[w + 2,h - 1,0] == l && v[w + 2,h ,0] == l && v[w + 2,h + 1,0] == l && v[w + 1,h + 2,0] == l && v[w ,h + 2,0] == l && v[w - 1,h + 2,0] == l && v[w - 2,h + 1,0] == l ) {v[w,h,1] = l;} // make line if isolated background pix } } } if(h >= 3 && h < H - 3) {if(w >= 3 && w < W - 3) {if(A8 > 3) {if(v[w,h,0] == l && v[w - 3,h ,0] == b && // case 4 - 36. previous 20 checks & 16 pix perimeter check v[w - 3,h - 1,0] == b && v[w - 2,h - 2,0] == b && v[w - 1,h - 3,0] == b && v[w ,h - 3,0] == b && v[w + 1,h - 3,0] == b && v[w + 2,h - 2,0] == b && v[w + 3,h - 1,0] == b && v[w + 3,h ,0] == b && v[w + 3,h + 1,0] == b && v[w + 2,h + 2,0] == b && v[w + 1,h + 3,0] == b && v[w ,h + 3,0] == b && v[w - 1,h + 3,0] == b && v[w - 2,h + 2,0] == b && v[w - 3,h + 1,0] == b ) {v[w,h,1] = b;} // make background if isolated line pix if(v[w,h,0] == b && v[w - 3,h ,0] == l && // case 4 - same for background v[w - 3,h - 1,0] == l && v[w - 2,h - 2,0] == l && v[w - 1,h - 3,0] == l && v[w ,h - 3,0] == l && v[w + 1,h - 3,0] == l && v[w + 2,h - 2,0] == l && v[w + 3,h - 1,0] == l && v[w + 3,h ,0] == l && v[w + 3,h + 1,0] == l && v[w + 2,h + 2,0] == l && v[w + 1,h + 3,0] == l && v[w ,h + 3,0] == l && v[w - 1,h + 3,0] == l && v[w - 2,h + 2,0] == l && v[w - 3,h + 1,0] == l ) {v[w,h,1] = l;} // make line if isolated background pix } } } if(A8 > 4) {if(h >= 1 && h < H-1) {if(w >= 1 && w < W-1) {if(A8 > 4) // case 5 connect lines {if(v[w,h,0] == b && v[w - 1,h ,1] == l && v[w + 1,h ,1] == l){v[w,h,1] = l;} if(v[w,h,0] == b && v[w ,h - 1,1] == l && v[w + 1,h + 1,1] == l){v[w,h,1] = l;} if(v[w,h,0] == b && v[w - 1,h - 1,1] == l && v[w + 1,h + 1,1] == l){v[w,h,1] = l;} if(v[w,h,0] == b && v[w - 1,h + 1,1] == l && v[w + 1,h - 1,1] == l){v[w,h,1] = l;} } // thicken lines case 6 if(A8 == 6) {if(v[w,h,0] == l && v[w,h,1] == l){v[w - 1,h - 1,1] = l;v[w ,h - 1,1] = l;v[w + 1,h - 1,1] = l; v[w - 1,h ,1] = l;v[w + 1,h ,1] = l; v[w - 1,h + 1,1] = l;v[w ,h + 1,1] = l;v[w + 1,h + 1,1] = l; } } } } } } } } for (int y = rect.Top; y < rect.Bottom; y++) // LOOP 3 - sets BGRA values, re-assembles and sends to dst canvas { for (int x = rect.Left; x < rect.Right; x++) { h = y - rect.Top; w = x - rect.Left; cp = src[x,y]; B = (int)cp.B; G = (int)cp.G; R = (int)cp.R; A = (int)cp.A; td = (int)dst[x,y].B +(int)dst[x,y].G + (int)dst[x,y].R;// destination - blurred pixel ts = B + G + R;// source - unblurred pixel lb = 0; lg = 0; lr = 0; la = 255; // set initial line variables to black bb = 255; bg = 255; br = 255; ba = 255; // set initial background variables to white switch (Amount4)// line properties {case 0: lb = PrimaryColor.B; lg = PrimaryColor.G; lr = PrimaryColor.R; la = PrimaryColor.A;break; //line colour = primary colour default black case 1: lb = B; lg = G; lr = R;la = 0;break; //transparent case 2: lb = B; lg = G; lr = R; la = A;break; // as original case 3: lb = dst[x,y].B; lg = dst[x,y].G; lr = dst[x,y].R; la = dst[x,y].A;break; // as blur case 4: lb = (int)(ts / 3);lg = (int)(ts / 3);lr = (int)(ts / 3);la = A;break; // src greys case 5: lb = (int)(td / 3);lg = (int)(td / 3);lr = (int)(td / 3);la = A;break; // dst greys case 6: lb = SecondaryColor.B;lg = SecondaryColor.G;lr = SecondaryColor.R;la = SecondaryColor.A;break;}// secondary colour switch (Amount5)//background properties {case 0: bb = SecondaryColor.B; bg = SecondaryColor.G; br = SecondaryColor.R; ba = SecondaryColor.A;break; //background colour = secondary colour default white case 1: bb = B; bg = G; br = R; ba = 0;break; //transparent case 2: bb = B; bg = G; br = R; ba = A;break; // as original case 3: bb = dst[x,y].B; bg = dst[x,y].G; br = dst[x,y].R; ba = dst[x,y].A;break;//as blur case 4: bb = (int)(ts / 3);bg = (int)(ts / 3);br = (int)(ts / 3);ba = A;break; // src greys case 5: bb = (int)(td / 3);bg = (int)(td / 3);br = (int)(td / 3);ba = A;break; // dst greys case 6: bb = PrimaryColor.B; bg = PrimaryColor.G; br = PrimaryColor.R; ba = PrimaryColor.A;break;}// primary if(v[w,h,1] == {B = bb; G = bg; R = br; A = ba;}//background values if(v[w,h,1] == l) {B = lb; G = lg; R = lr; A = la;}//outline values if(Amount9 == 1 && v[w,h,0] == l && v[w,h,1] == {B = 128;G = 128; R = 0; A = 255;} // if changed line single pixel make cyan if(Amount9 == 1 && v[w,h,0] == b && v[w,h,1] == l){B = 0;G = 0; R = 255; A = 255;} // if changed background single pixel make red // re assemble cp = ColorBgra.FromBgra( Int32Util.ClampToByte(, Int32Util.ClampToByte(G), Int32Util.ClampToByte(R), Int32Util.ClampToByte(A)); dst[x,y] = cp; } } }
  6. I also had an error involving SetUpFrontend.exe when installing 3.5.7. I'm attaching the screenshot of the warning - but paint.net seems to still be working o.k.? Sorry this doesn't help you - but it may help those trying to fix it? Edit: - I removed the screenshot to save upload space - It's irrelevant now were v3.5.10 too!
  7. Hello all, I've attached the dll of the re-written contour plugin. The code should be below. /* =================================================== */ /* */ /* Contour.cs */ /* (c) 2011 John Robbins (Red Ochre) */ /* */ /* Description: creates contours based on an images luminosity */ /* */ /* ========================================== ======== */ // Name: Contour // Author: Red Ochre (John Robbins) // Submenu: Stylize // URL: http://www.getpaint.net/redirect/plugins.html // Title: Contour - 2011 Red Ochre #region UICode int Amount1 = 25; //[0,100]smoothness (blur radius) int Amount2 = 5; //[1,50]number of contours n double Amount3 = 0.5; //[0.01,1.00]contour/gap ratio ColorBgra Amount4 = ColorBgra.FromBgr(250,250,25); //contour colour byte Amount5 = 0; //contour properties|rainbow|background|transparent|solid colour|shaded across contour|shaded along contour|shade both ways|both ways from source(speckled) ColorBgra Amount6 = ColorBgra.FromBgr(25,25,250); //gap colour byte Amount7 = 7; //gap properties|background|transparent|solid colour|shaded across gap|shaded along gap|shade both ways|both ways from source(speckled)|rainbow #endregion void Render(Surface dst, Surface src, Rectangle rect) { // Call the Gaussian Blur effect GaussianBlurEffect blurEffect = new GaussianBlurEffect(); PropertyCollection bProps = blurEffect.CreatePropertyCollection(); PropertyBasedEffectConfigToken bParameters = new PropertyBasedEffectConfigToken(bProps); bParameters.SetPropertyValue(GaussianBlurEffect.PropertyNames.Radius, Amount1); blurEffect.SetRenderInfo(bParameters, new RenderArgs(dst), new RenderArgs(src)); blurEffect.Render(new Rectangle[1] {rect},0,1); ColorBgra CurrentPixel; int B, G, R, A, tc, tg; double rad = Math.PI * 2; for(int y = rect.Top; y < rect.Bottom; y++) { for (int x = rect.Left; x < rect.Right; x++) { CurrentPixel = dst[x,y]; B = (int)CurrentPixel.B; G = (int)CurrentPixel.G; R = (int)CurrentPixel.R; A = (int)CurrentPixel.A; int n = Amount2; // n = number of contours from slider int bothw = 765/n; // cw + gw (cw = contour width, gw = gap width) int cw = (int)(bothw * Amount3); // contour width as ratio of 'bothw' int gw = bothw - cw; // gap width is the remainder int tv = B + G + R; // tone value from current (blurred) int ts = (int)src[x,y].B + (int)src[x,y].G + (int)src[x,y].R; // ts = source (unblurred) tone value if(Amount5 == 7){tc = ts;} // change tone value to unblurred for speckled option else {tc = tv;} if(Amount7 == 6){tg = ts;} else {tg = tv;} for (int z = 0; z < n + 1; z++) // contour and gap loop { int thresh0 = bothw * z; // thresholds ... gap starts int thresh1 = thresh0 + cw; // thresholds ... gap ends, contour starts int thresh2 = thresh0 + bothw; // thresholds ... contour ends, gap starts double rat = (double)tc / 765; // long ways shading factor double midcont = ((thresh2 - thresh1) / 2) + thresh1 ; // contour mid point double midgap = ((thresh1 - thresh0) / 2) + thresh0 ; // gap mid point double c1, c2; //crossways shading multipliers double f = 2.0; // factor to lighten the bothways shading mode int gB = Amount6.B; int gG = Amount6.G; int gR = Amount6.R; int gA = Amount6.A; // gap colours int cB = Amount4.B; int cG = Amount4.G; int cR = Amount4.R; int cA = Amount4.A; // contour colours // Gap if (tv >= thresh0 && tv < thresh1) {switch(Amount7) {case 0: // background B = (int)src[x,y].B;G = (int)src[x,y].G;R = (int)src[x,y].R;A = (int)src[x,y].A; break; case 1: // transparent A = 0; break; case 2: // solid colour B = gB; G = gG; R = gR; A = gA; break; case 3: // shade across if(tv < midgap) {c1 = (tv - thresh0) / (midgap - thresh0); B = (int)(gB * c1); G = (int)(gG * c1); R = (int)(gR * c1); A = gA;} if(tv == midgap){B = gB; G = gG; R = gR; A = gA;} if(tv > midgap) {c2 = (thresh1 - tv) / (thresh1 - midgap); B = (int)(gB * c2); G = (int)(gG * c2); R = (int)(gR * c2); A = gA;} break; case 4: // shade along B = (int)(gB * rat); G = (int)(gG * rat); R = (int)(gR * rat); A = gA; break; case 5: // both ways if(tv < midgap) {c1 = (tv - thresh0) / (midgap - thresh0); B = (int)(gB * c1 * rat * f); G = (int)(gG * c1 * rat * f); R = (int)(gR * c1 * rat * f); A = gA;} if(tv == midgap){B = (int)(gB * rat * f); G = (int)(gG * rat * f); R = (int)(gR * rat * f); A = gA;} if(tv > midgap) {c2 = (thresh1 - tv) / (thresh1 - midgap); B = (int)(gB * c2 * rat * f); G = (int)(gG * c2 * rat * f); R = (int)(gR * c2 * rat * f); A = gA;} break; case 6: // both from source if(tg < midgap) {c1 = (tg - thresh0) / (midgap - thresh0); B = (int)(gB * c1 * rat * f); G = (int)(gG * c1 * rat * f); R = (int)(gR * c1 * rat * f); A = gA;} if(tg == midgap){B = (int)(gB * rat * f); G = (int)(gG * rat * f); R = (int)(gR * rat * f); A = gA;} if(tg > midgap) {c2 = (thresh1 - tg) / (thresh1 - midgap); B = (int)(gB * c2 * rat * f); G = (int)(gG * c2 * rat * f); R = (int)(gR * c2 * rat * f); A = gA;} break; case 7: // rainbow if(tv <= midgap) {c1 = (tv - thresh0) / (midgap - thresh0); double b1 = Math.Sin(c1 * rad * 4 / 3); double g1 = Math.Sin(c1 * rad * 5 / 3); double r1 = Math.Sin(c1 * rad * 6 / 3); B = (int)((gB * c1) + (128 * b1)); G = (int)((gG * c1) + (128 * g1)); R = (int)((gR * c1) + (128 * r1)); A = gA;} if(tv > midgap) {c2 = (thresh1 - tv) / (thresh1 - midgap); double b2 = Math.Sin(c2 * rad * 4 / 3); double g2 = Math.Sin(c2 * rad * 5 / 3); double r2 = Math.Sin(c2 * rad * 6 / 3); B = (int)((gB * c2) + (128 * b2)); G = (int)((gG * c2) + (128 * g2)); R = (int)((gR * c2) + (128 * r2)); A = gA;} break; } } // Contour if (tv >= thresh1 && tv < thresh2) {switch(Amount5) {case 0: //rainbow if(tv <= midcont) {c1 = (tv - thresh1) / (midcont - thresh1); double b1 = Math.Sin(c1 * rad * 4 / 3); double g1 = Math.Sin(c1 * rad * 5 / 3); double r1 = Math.Sin(c1 * rad * 6 / 3); B = (int)((cB * c1) + (128 * b1)); G = (int)((cG * c1) + (128 * g1)); R = (int)((cR * c1) + (128 * r1)); A = cA;} if(tv > midcont) {c2 = (thresh2 - tv) / (thresh2 - midcont); double b2 = Math.Sin(c2 * rad * 4 / 3); double g2 = Math.Sin(c2 * rad * 5 / 3); double r2 = Math.Sin(c2 * rad * 6 / 3); B = (int)((cB * c2) + (128 * b2)); G = (int)((cG * c2) + (128 * g2)); R = (int)((cR * c2) + (128 * r2)); A = cA;} break; case 1: // background B = (int)src[x,y].B;G = (int)src[x,y].G;R = (int)src[x,y].R;A = (int)src[x,y].A; break; case 2: // transparent A = 0; break; case 3: // solid colour B = cB; G = cG; R = cR; A = cA; break; case 4: // shade across if(tv < midcont) {c1 = (tv - thresh1) / (midcont - thresh1); B = (int)(cB * c1); G = (int)(cG * c1); R = (int)(cR * c1); A = cA;} if(tv == midcont){B = cB; G = cG; R = cR; A = cA;} if(tv > midcont) {c2 = (thresh2 - tv) / (thresh2 - midcont); B = (int)(cB * c2); G = (int)(cG * c2); R = (int)(cR * c2); A = cA;} break; case 5: // shade along B = (int)(cB * rat); G = (int)(cG * rat); R = (int)(cR * rat); A = cA; break; case 6: // both ways f = factor to lighten if(tv < midcont) {c1 = (tv - thresh1) / (midcont - thresh1); B = (int)(cB * c1 * rat * f); G = (int)(cG * c1 * rat * f); R = (int)(cR * c1 * rat * f); A = cA;} if(tv == midcont){B = (int)(cB * rat * f); G = (int)(cG * rat * f); R = (int)(cR * rat * f); A = cA;} if(tv > midcont) {c2 = (thresh2 - tv) / (thresh2 - midcont); B = (int)(cB * c2 * rat * f); G = (int)(cG * c2 * rat * f); R = (int)(cR * c2 * rat * f); A = cA;} break; case 7: //both from source f = factor to lighten if(tc < midcont) {c1 = (tc - thresh1) / (midcont - thresh1); B = (int)(cB * c1 * rat * f); G = (int)(cG * c1 * rat * f); R = (int)(cR * c1 * rat * f); A = cA;} if(tc == midcont){B = (int)(cB * rat * f); G = (int)(cG * rat * f); R = (int)(cR * rat * f); A = cA;} if(tc > midcont) {c2 = (thresh2 - tc) / (thresh2 - midcont); B = (int)(cB * c2 * rat * f); G = (int)(cG * c2 * rat * f); R = (int)(cR * c2 * rat * f); A = cA;} break; } } // re assemble CurrentPixel = ColorBgra.FromBgra( Int32Util.ClampToByte(, Int32Util.ClampToByte(G), Int32Util.ClampToByte(R), Int32Util.ClampToByte(A)); dst[x,y] = CurrentPixel; } } } } Now in my plugin pack Red ochre plugin pack
  8. Hello again, I've reworked the effects formerly known as "Earths", which is now "Earths and greys", and "psychocolour"is also attached. Hopefully the code is a lot more readable now ? I haven't started on "contour" yet - as I want to fully rewrite it. Is this the best forum to 'publish' them, or should I have started a new thread? Thanks for the help. /* =================================================== */ /* */ /* Color EarthsnGreys.cs */ /* (c) 2011 Red Ochre */ /* */ /* Description: simplifies tones with choice of palettes */ /* */ /* ========================================== ======== */ // Name: EarthsnGreys // Author: Red Ochre // Submenu: Color // URL: http://www.getpaint.net/redirect/plugins.html // Title: Earths and Greys - 2011 Red Ochre #region UICode int Amount1 = 5; //[0,100]blur radius int Amount2 = 220; //[0,255]threshold 1 (whitest above) int Amount3 = 190; //[0,255]threshold 2 int Amount4 = 160; //[0,255]threshold 3 int Amount5 = 130; //[0,255]threshold 4 (midtone) int Amount6 = 100; //[0,255]threshold 5 int Amount7 = 70; //[0,255]threshold 6 int Amount8 = 40; //[0,255]threshold 7 (blackest below) byte Amount9 = 7; // colour palette|earth colours|close tone greys|full range greys|warm to cool neutrals|YORMBCG toned rainbow|YORMBCG straight rainbow|YORMBCG flat toned rainbow|reverse clashing rainbow #endregion void Render(Surface dst, Surface src, Rectangle rect) { // Call the Gaussian Blur effect GaussianBlurEffect blurEffect = new GaussianBlurEffect(); PropertyCollection bProps = blurEffect.CreatePropertyCollection(); PropertyBasedEffectConfigToken bParameters = new PropertyBasedEffectConfigToken(bProps); bParameters.SetPropertyValue(GaussianBlurEffect.PropertyNames.Radius, Amount1); blurEffect.SetRenderInfo(bParameters, new RenderArgs(dst), new RenderArgs(src)); blurEffect.Render(new Rectangle[1] {rect},0,1); ColorBgra CurrentPixel; int B, G, R, A; int B1,B2,B3,B4,B5,B6,B7,B8,G1,G2,G3,G4,G5,G6,G7,G8,R1,R2,R3,R4,R5,R6,R7,R8; B1 = 186;B2 = 130;B3 = 40; B4 = 30; B5 = 25; B6 = 10; B7 = 10;B8 = 10; // had to put some values here or unassigned variable problem G1 = 255;G2 = 220;G3 = 180;G4 = 125;G5 = 80; G6 = 40; G7 = 40;G8 = 20; R1 = 246;R2 = 240;R3 = 240;R4 = 190;R5 = 200;R6 = 130;R7 = 70;R8 = 20; for(int y = rect.Top; y < rect.Bottom; y++) { for (int x = rect.Left; x < rect.Right; x++) { switch (Amount9) { case 0: // earth colours B1 = 186;B2 = 130;B3 = 48; B4 = 30; B5 = 25; B6 = 10; B7 = 10;B8 = 10; G1 = 255;G2 = 220;G3 = 173;G4 = 125;G5 = 80; G6 = 40; G7 = 40;G8 = 20; R1 = 246;R2 = 240;R3 = 201;R4 = 190;R5 = 200;R6 = 130;R7 = 70;R8 = 20; break; case 1: // close tone greys B1 = 224;B2 = 196;B3 = 168;B4 = 140;B5 = 112;B6 = 84;B7 = 56;B8 = 28; G1 = 224;G2 = 196;G3 = 168;G4 = 140;G5 = 112;G6 = 84;G7 = 56;G8 = 28; R1 = 224;R2 = 196;R3 = 168;R4 = 140;R5 = 112;R6 = 84;R7 = 56;R8 = 28; break; case 2: // full range greys B1 = 255;B2 = 219;B3 = 182;B4 = 146;B5 = 109;B6 = 73;B7 = 37;B8 = 0; G1 = 255;G2 = 219;G3 = 182;G4 = 146;G5 = 109;G6 = 73;G7 = 37;G8 = 0; R1 = 255;R2 = 219;R3 = 182;R4 = 146;R5 = 109;R6 = 73;R7 = 37;R8 = 0; break; case 3: // warm to cool neutrals B1 = 193;B2 = 173;B3 = 154;B4 = 134;B5 = 115;B6 = 95;B7 = 75;B8 = 56; G1 = 224;G2 = 196;G3 = 168;G4 = 140;G5 = 112;G6 = 84;G7 = 56;G8 = 28; R1 = 255;R2 = 219;R3 = 182;R4 = 146;R5 = 109;R6 = 73;R7 = 37;R8 = 0; break; case 4: // toned rainbow // White Yellow Orange Red Magenta Blue Cyan Green B1 = 255;B2 = 146;B3 = 97;B4 = 91;B5 = 165;B6 = 220;B7 = 55;B8 = 0; G1 = 255;G2 = 255;G3 = 195;G4 = 92;G5 = 0;G6 = 0;G7 = 56;G8 = 16; R1 = 255;R2 = 255;R3 = 255;R4 = 255;R5 = 164;R6 = 0;R7 = 0;R8 = 0; //sum = 765, 656, 547, 438, 329, 220, 111, 16 break; case 5: // straight rainbow // White Yellow Orange Red Magenta Blue Cyan Green B1 = 255;B2 = 0;B3 = 0;B4 = 0;B5 = 255;B6 = 255;B7 = 255;B8 = 0; // note: orange is not G1 = 255;G2 = 255;G3 = 128;G4 = 0;G5 = 0;G6 = 0;G7 = 255;G8 = 255; // a perfect division of R1 = 255;R2 = 255;R3 = 255;R4 = 255;R5 = 255;R6 = 0;R7 = 0;R8 = 0; // the spectrum //sum = 765, 510, 383, 255, 510, 255, 510, 255 break; case 6: // flat toned rainbow // Grey Yellow Orange Red Magenta Blue Cyan Green B1 = 170;B2 = 0;B3 = 85;B4 = 128;B5 = 255;B6 = 255;B7 = 255;B8 = 128; G1 = 170;G2 = 255;G3 = 170;G4 = 127;G5 = 0; G6 = 128;G7 = 255;G8 = 255; R1 = 170;R2 = 255;R3 = 255;R4 = 255;R5 = 255;R6 = 127;R7 = 0;R8 = 127; //sum = 510, 510, 510, 510, 510, 510, 510, 510 break; case 7: // reverse clashing rainbow // White Magenta Blue Cyan Green Yellow Orange Red B1 = 255;B2 = 255;B3 = 255;B4 = 255;B5 = 182;B6 = 72;B7 = 100;B8 = 128; G1 = 255;G2 = 217;G3 = 218;G4 = 255;G5 = 255;G6 = 255;G7 = 191;G8 = 128; R1 = 255;R2 = 255;R3 = 218;R4 = 144;R5 = 181;R6 = 255;R7 = 255;R8 = 255; //sum = 765, 727, 691, 654, 618, 582, 546, 510 break; } CurrentPixel = dst[x,y]; B = (int)CurrentPixel.B; G = (int)CurrentPixel.G; R = (int)CurrentPixel.R; A = (int)CurrentPixel.A; int mylum = (R + G + / 3; // band 1 - white if (mylum >= Amount2) {B = B1; G = G1; R = R1;} // band 2 if (mylum >= Amount3 && mylum < Amount2){B = B2; G = G2; R = R2;} // band 3 if (mylum >= Amount4 && mylum < Amount3){B = B3; G = G3; R = R3;} // band 4 if (mylum >= Amount5 && mylum < Amount4){B = B4; G = G4; R = R4;} // band 5 if (mylum >= Amount6 && mylum < Amount5){B = B5; G = G5; R = R5;} // band 6 if (mylum >= Amount7 && mylum < Amount6){B = B6; G = G6; R = R6;} // band 7 if (mylum >= Amount8 && mylum < Amount7){B = B7; G = G7; R = R7;} // band 8 if (mylum < Amount8) {B = B8; G = G8; R = R8;} // re assemble CurrentPixel = ColorBgra.FromBgra( Int32Util.ClampToByte(, Int32Util.ClampToByte(G), Int32Util.ClampToByte(R), Int32Util.ClampToByte(A)); dst[x,y] = CurrentPixel; } } } /* =================================================== */ /* */ /* Color Psycocolour.cs */ /* (c) 2011 Red Ochre */ /* */ /* Description: various psychedelic colour effects */ /* */ /* ========================================== ======== */ // Name: Psycocolour // Author: Red Ochre // Submenu: Color // URL: http://www.getpaint.net/redirect/plugins.html // Title: Psychocolour - 2011 Red Ochre #region UICode byte Amount1 = 5; // effect|colour phase shift|tone phase shift|alter by others|seperate colours by others|strange pointillism|out of phase shift double Amount2 = 0.5; // [0.0,1.0] phase shift #endregion void Render(Surface dst, Surface src, Rectangle rect) { ColorBgra CurrentPixel; int B,G,R,A; double f = Amount2; double rad = Math.PI*2; double phaseB,phaseG,phaseR; for (int y = rect.Top; y < rect.Bottom; y++) { for (int x = rect.Left; x < rect.Right; x++) { CurrentPixel = src[x,y]; B = CurrentPixel.B; G = CurrentPixel.G; R = CurrentPixel.R; A = CurrentPixel.A; double lum = B + G + R; double rat = lum / 765.0; double b = B / 255.0; double bangle = b * rad; double g = G / 255.0; double gangle = g * rad; double r = R / 255.0; double rangle = r * rad; switch(Amount1) { case 0: // colour phase shift B = 128 + (int)(128 * Math.Sin((bangle + (rad * 1 * f)))); G = 128 + (int)(128 * Math.Sin((gangle + (rad * 2 * f)))); R = 128 + (int)(128 * Math.Sin((rangle + (rad * 3 * f)))); break; case 1: // tone phase shift phaseB = (1.0 / 3.0) * rad * f; phaseG = (2.0 / 3.0) * rad * f; phaseR = (3.0 / 3.0) * rad * f; B = 128 + (int)(128 * Math.Sin((rat + phaseB) * rad)); G = 128 + (int)(128 * Math.Sin((rat + phaseG) * rad)); R = 128 + (int)(128 * Math.Sin((rat + phaseR) * rad)); break; case 2: // alter each colour by the sum of the other 2 phaseB = ((B + (255 * f)) / (G + R + 1)) * rad; // add 1 to denominator incase G + R = 0 phaseG = ((G + (255 * f)) / (R + B + 1)) * rad; phaseR = ((R + (255 * f)) / (B + G + 1)) * rad; B = 128 - (int)(128 * Math.Sin(phaseB)); G = 128 - (int)(128 * Math.Sin(phaseG)); R = 128 - (int)(128 * Math.Sin(phaseR)); break; case 3: // seperate colours by others b = (G + R) / 510.0; bangle = b * rad; g = (R + / 510.0; gangle = g * rad; r = (B + G) / 510.0; rangle = r * rad; B = B + (int)(B * Math.Cos((bangle + (rad * 1 * f)))); G = G + (int)(G * Math.Cos((gangle + (rad * 1 * f)))); R = R + (int)(R * Math.Cos((rangle + (rad * 1 * f)))); break; case 4: // strange pointillism double ave = lum / 3; double Bdif = ave - B; bangle = f * Bdif; double Gdif = ave - G; gangle = f * Gdif; double Rdif = ave - R; rangle = f * Rdif; B = (int)(B + (ave * Math.Sin(bangle))); G = (int)(G + (ave * Math.Sin(gangle))); R = (int)(R + (ave * Math.Sin(rangle))); break; case 5: // out of phase shift phaseB = rad * b / (f + 0.01); // avoid divide by zero phaseG = rad * g / (f + 0.01); phaseR = rad * r / (f + 0.01); B = B + (int)(B * (Math.Cos(phaseB) - Math.Sin(phaseB))); G = G + (int)(G * (Math.Cos(phaseG) - Math.Sin(phaseG))); R = R + (int)(R * (Math.Cos(phaseR) - Math.Sin(phaseR))); break; } // re assemble CurrentPixel = ColorBgra.FromBgra( Int32Util.ClampToByte(, Int32Util.ClampToByte(G), Int32Util.ClampToByte(R), Int32Util.ClampToByte(A)); dst[x,y] = CurrentPixel; } } }
  9. I'm working on the next version now, but probably won't post it tonight. Thanks for reviewing the last one - all useful points. The next one should be tidier.
  10. Actually the color wheel seems to be behaving ok now
  11. Thanks for all that work - it is clearer. One thing though - that's actually the code for 'Phsycocolour2' -my fault for uploading them in the wrong order and not adding the the title at the top. I intend to add more strange effects to this one, as I can just add a new 'case, break' for each block. The dlls are correctly named but I will rewrite the code to make it tidier and more readable, and possibly organise UI more logically too. One question - the colour wheel always seems to default to the primary colour setting despite giving it a value in the UI code. Is that just the way it is or can it be made to take the initial value I've assigned ? Thanks again for the work - I've got loads to learn/discover - I tend to litter the code with casts when I'm 'debugging', then find the fault is somewhere else and forget to go back and write things as simply as possible - lazy habits already!
  12. Thanks - I will improve the readability next time, before I send them - they've sort of evolved rather than being logically designed, bits added as I've found out what things do. Thanks for corecting the / code mistake, sorry again - will try out the Int32Util.. option. I will be back tommorow - I've got plenty of questions - if you have the patience
  13. Whoops - sorry didn't add the "[/code]" at the end.
  14. Thought it time to show you how messy my code is - but it seems to run ok for me and it's the first stuff I've written since the Commodore 64. dlls zipped and attached hopefully. #region UICode byte Amount1 = 1; // effect|seperate colour phase shift|luminosity phase shift double Amount2 = 0.0; // [0.0,1.0] phase shift #endregion private byte Clamp2Byte (int iValue) {if (iValue<0) return 0; if (iValue>255) return 255; return (byte) iValue;} void Render(Surface dst, Surface src, Rectangle rect) { ColorBgra CurrentPixel; int B,G,R,A; double f = Amount2; for (int y = rect.Top; y < rect.Bottom; y++) for (int x = rect.Left; x < rect.Right; x++) { {CurrentPixel = src[x,y]; B = CurrentPixel.B; G = CurrentPixel.G; R = CurrentPixel.R; A = CurrentPixel.A; switch((int)Amount1){ case 0: //seperate colour phase shift double rad = Math.PI*2; double phaseB = ((double) 3.0/(double) 3.0*f)*rad; double phaseG = ((double) 1.0/(double) 3.0*f)*rad; double phaseR = ((double) 2.0/(double) 3.0*f)*rad; double b = (double)B/255;double bangle = b*rad;B = 128+(int)(128*Math.Sin((bangle+(rad*f)))); double g = (double)G/255;double gangle = g*rad;G = 128+(int)(128*Math.Sin((gangle+(rad*2*f)))); double r = (double)R/255;double rangle = r*rad;R = 128+(int)(128*Math.Sin((rangle+(rad*4*f)))); break; case 1: // luminosity phase shift double lum = (double)B+(double)G+(double)R; double rat = (double) lum/ (double)765; rad = Math.PI*2; phaseB = ((double) 3.0/(double) 3.0)*rad*(f+1);B = 128 + (int)(rat*(128*Math.Sin((rat*rad)+(phaseB*rad)))); phaseG = ((double) 2.0/(double) 3.0)*rad*(f+1);G = 128 + (int)(rat*(128*Math.Sin((rat*rad)+(phaseG*rad)))); phaseR = ((double) 1.0/(double) 3.0)*rad*(f+1);R = 128 + (int)(rat*(128*Math.Sin((rat*rad)+(phaseR*rad)))); break; } // re assemble CurrentPixel = ColorBgra.FromBgra(Clamp2Byte(,Clamp2Byte(G),Clamp2Byte(R),Clamp2Byte(A)); dst[x,y] = CurrentPixel; } } } #region UICode int Amount1=5; //[0,100]blur radius int Amount2=220; //[0,255]Flake white threshold int Amount3=190; //[0,255]Naples yellow threshold int Amount4=160; //[0,255]Yellow ochre threshold int Amount5=130; //[0,255]Raw Sienna threshold int Amount6=100; //[0,255]English red ochre threshold int Amount7=70; //[0,255]Burnt Umber threshold int Amount8=40; //[0,255]Raw Umber threshold #endregion private byte Clamp2Byte(int iValue) { if (iValue<0) return 0; if (iValue>255) return 255; return (byte)iValue; } void Render(Surface dst, Surface src, Rectangle rect) { // Call the Gaussian Blur effect GaussianBlurEffect blurEffect = new GaussianBlurEffect(); PropertyCollection bProps = blurEffect.CreatePropertyCollection(); PropertyBasedEffectConfigToken bParameters = new PropertyBasedEffectConfigToken(bProps); bParameters.SetPropertyValue(GaussianBlurEffect.PropertyNames.Radius, Amount1); blurEffect.SetRenderInfo(bParameters, new RenderArgs(dst), new RenderArgs(src)); blurEffect.Render(new Rectangle[1] {rect},0,1); ColorBgra CurrentPixel; int R, G, B, A; for(int y = rect.Top; y < rect.Bottom; y++) { for (int x = rect.Left; x < rect.Right; x++) { CurrentPixel = dst[x,y]; B = (int)CurrentPixel.B; G = (int)CurrentPixel.G; R = (int)CurrentPixel.R; A = (int)CurrentPixel.A; int mylum = (R + G + B)/3; // Flake white if (mylum >= Amount2) { B = 210; G = 250; R = 250; } // Naples yellow if (mylum >= Amount3 && mylum < Amount2) { B = 130; G = 220; R = 240; } // Yellow ochre if (mylum >= Amount4 && mylum < Amount3) { B = 40; G = 180; R = 240; } // Raw Sienna if (mylum >= Amount5 && mylum < Amount4) { B = 30; G = 125; R = 190; } // English red ochre if(mylum>=Amount6 && mylum<Amount5) { B = 25; G = 80; R = 200; } // Burnt Umber if(mylum>=Amount7 && mylum<Amount6) { B = 10; G = 40; R = 130; } // Raw Umber if(mylum>=Amount8 && mylum<Amount7) { B = 10; G = 40; R = 70; } // Lamp black if(mylum<Amount8) { B = 10; G = 20; R = 20; } // Reassemble the color from R, G, and B CurrentPixel = ColorBgra.FromBgra(Clamp2Byte(,Clamp2Byte(G),Clamp2Byte(R),Clamp2Byte(A)); dst[x,y] = CurrentPixel; } } } #region UICode ColorBgra Amount1 = ColorBgra.FromBgr(220,220,200); // colour to detect int Amount2 = 15; // [0,765] detection tolerance ColorBgra Amount3 = ColorBgra.FromBgr(170,170,190); // replacement colour byte Amount4 =5; //blend type|none|blend1|old blend|dompix|fun|minus 1 add 2 int Amount5 = 150; // [0,765] blend tolerance int Amount6 = 255; // [0,255] replacement transparency #endregion private byte Clamp2Byte(int iValue) { if (iValue<0) return 0; if (iValue>255) return 255; return (byte)iValue; } void Render(Surface dst, Surface src, Rectangle rect) { ColorBgra CurrentPixel; int B, G, R,A,lum, B1,G1,R1,A1,lum1, B2,G2,R2,A2,lum2, t1,t2,t3, dB2,dG2,dR2,dA2, obt,ogt,ort,oat, tb,tg,tr,ta, f1,f2,f3 ; int nbt,ngt,nrt,nat, Q,C; for(int y = rect.Top; y < rect.Bottom; y++) { for (int x = rect.Left; x < rect.Right; x++) { CurrentPixel = src[x,y]; C=Amount4; B = (int)CurrentPixel.B; // source pixel G = (int)CurrentPixel.G; R = (int)CurrentPixel.R; A = (int)CurrentPixel.A; lum=B+G+R; B1 = (int)Amount1.B; // colour to detect G1 = (int)Amount1.G; R1 = (int)Amount1.R; A1 = (int)Amount1.A; lum1=B1+G1+R1; t1 = (int)Amount2; //detection tolerance t2 = (int)Amount5; //blend tolerance t3 = t1+t2; f1 = t1/3; f2 = t2/3; f3 = t3/3; B2 = (int)Amount3.B; // replacement colour G2 = (int)Amount3.G; R2 = (int)Amount3.R; A2 = (int)Amount6; lum2=B2+G2+R2; dB2 = B2-B; dG2 = G2-G; dR2 = R2-R; dA2 = A2-A; obt=B*(dB2);ogt=G*(dG2);ort=R*(dR2);oat=A*(dA2); // this blends but not right tb=(255-dB2)*B2;tg=(255-dG2)*G2;tr=(255-dR2)*R2;ta=(255-dA2)*A2; nbt=(obt+tb)/255;ngt=(ogt+tg)/255;nrt=(ort+tr)/255;nat=(oat+ta)/255; if(lum>lum1-t1&&lum<=lum1+t1){B=B2;G=G2;R=R2;A=A2;}// replace with new colour switch((int)Amount4) {case 0: //no blend break; case 1: //new blend with full transparency if(lum>=lum1+t1&&lum<lum1+t3){Q=lum-(lum1+t1);//upper blend band B=((B*Q*255)+(B2*(t2-Q)*255))/(t2*255); G=((G*Q*255)+(G2*(t2-Q)*255))/(t2*255); R=((R*Q*255)+(R2*(t2-Q)*255))/(t2*255); A=((A*Q*255)+(A2*(t2-Q)*255))/(t2*255);} if(lum>lum1-t3&&lum<=lum1-t1){Q=lum-(lum1-t3); //lower blend band B=((B*(t2-Q)*255)+(B2*Q*255))/(t2*255); G=((G*(t2-Q)*255)+(G2*Q*255))/(t2*255); R=((R*(t2-Q)*255)+(R2*Q*255))/(t2*255); A=((A*(t2-Q)*255)+(A2*Q*255))/(t2*255);} break; case 2: //original blend if(lum>=lum1+t1&&lum<lum1+t3){B=nbt;G=ngt;R=nrt;A=nat;} //upper blend band if(lum>lum1-t3&&lum<=lum1-t1){B=nbt;G=ngt;R=nrt;A=nat;} //lower blend band break; case 3: //predominant pixel won't blend upper band because colour 2 is too high - have reversed preferencein highband if(lum>=lum1+t1&&lum<lum1+t3){if(B2<[img=http://forums.getpaint.net/public/style_emoticons/default/boltbait.cool.png]{B=B2;}if(R2<R){R=R2;}if(G2<G){G=G2;}if(A2<A){A=A2;}} //upper blend band if(lum>lum1-t3&&lum<=lum1-t1){if(B2<[img=http://forums.getpaint.net/public/style_emoticons/default/boltbait.cool.png]{B=B2;}if(R2<R){R=R2;}if(G2<G){G=G2;}if(A2<A){A=A2;}} //lower blend band break; case 4: // fun if(B>B1+f1&&B<=B1+f3){B=B2;} //upper band if(G>G1+f1&&G<=G1+f3){G=G2;} if(R>R1+f1&&R<=R1+f3){R=R2;} if((B>B1+f1&&B<=B1+f3)||(G>G1+f1&&G<=G1+f3)||(R>R1+f1&&R<=R1+f3)){A=A2;} if(B<=(B1-f1)&&B>(B1-f3)){B=B2;} //lower band if(G<=(G1-f1)&&G>(G1-f3)){G=G2;} if(R<=(R1-f1)&&B>(R1-f3)){R=R2;} if((B<=(B1-f1)&&B>(B1-f3))||(G<=(G1-f1)&&G>(G1-f3))||((R<=(R1-f1)&&B>(R1-f3)))){A=A2;} break; case 5: //subtract colour 1 and add colour 2 if(lum>=lum1+t1&&lum<lum1+t3){B=(B+B2)-B1; G=(G+G2)-G2; R=(R+R2)-R1; A=(A+A2)-A1;} //upper blend band if(lum>lum1-t3&&lum<=lum1-t1){B=(B+B2)-B1; G=(G+G2)-G1; R=(R+R2)-R1; A=(A+A2)+A1;} //lower blend band break; } // Reassemble the color from B, G, and R CurrentPixel = ColorBgra.FromBgra(Clamp2Byte([img=http://forums.getpaint.net/public/style_emoticons/default/boltbait.cool.png],Clamp2Byte(G),Clamp2Byte®,Clamp2Byte(A)); dst[x,y] = CurrentPixel; } } }
  15. Thanks for the reply. - I just wanted to play with generating lines without refence to the src at this stage. Later I would like to pick out say dark pixels( B+G+R<= Amount1) then use this to create the co-ordinates for the g.Drawline command. - Very ambitious, but what's to loose. Do you know if this(the cs0012 thing) is known issue with Codelab, or is it just me? I will post some (ametuerish) beta plugins shortly, just got to reread the rules and zip them up. Thanks again
  16. As a new member, firstly, thank you for Paint.net and Codelab. I have no C# experience but have still managed to write some plugins that I am very pleased with. The problem I have is with the default code for copying the source to the destination without using the loops. When I use the 'new' option and select the option to include this, it adds the code, but the errors window shows two cs0012 errors. This also happens if I write the code manually copying from tutorial4. (dst.CopySurface(src,rect.Location,rect;). The error says: "System.Windows.Int32Rect must add reference to WindowsBase,Version=3.0.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35 (cs0012)" and the same reference with "System.Windows.Point". I have tried copying and pasting the code into visual express, but I really am a novice and can't see a way of adding the relevant reference. I really do not yet understand visual express. Is this a known issue, or is it my set up? Can it be resolved or do I just have to use the loops to copy everything over before rendering anything new? Presumably there should be some sort of 'using' statement in the 'hidden' code which points to the relevant library, but since I don't know where this is or the correct syntax to add it - I'm stuck. Any advice will be appreciated.