hollander
-
Posts
11 -
Joined
-
Last visited
Posts posted by hollander
-
-
This one took me quite a while. The real picture is bigger and includes the rest of the body. (I didn't upload the full picture because she is not wearing a lot of clothes and that may be found "ofensive" (rules))
-
it is hair (obviously). It took a lot of effort, but it turned out pretty nice.
the background is transparent and you are free to use it.
-
Uh... you can't add a byte to a int.
you can.
-
I cant figure out what makes it crashes, the values m and m2 are always higher than 1
int Amount1=0; //[0,1]mode: black/wite -- color int Amount2=128; //[0,255]brightness int Amount3=0; //[0,100]dither int m; float m2; float m3; int r; int g; int b; int r2; int g2; int b2; int mr=124; int mg=872; int mb=164; void Render(Surface dst, Surface src, Rectangle rect) { PdnRegion selectionRegion = EnvironmentParameters.GetSelection(src.Bounds); // Delete any of these lines you don't need Rectangle selection = this.EnvironmentParameters.GetSelection(src.Bounds).GetBoundsInt(); long CenterX = (long)(((selection.Right - selection.Left) / 2)+selection.Left); long CenterY = (long)(((selection.Bottom - selection.Top) / 2)+selection.Top); ColorBgra PrimaryColor = (ColorBgra)EnvironmentParameters.PrimaryColor; ColorBgra SecondaryColor = (ColorBgra)EnvironmentParameters.SecondaryColor; int BrushWidth = (int)EnvironmentParameters.BrushWidth; ColorBgra CurrentPixel; for(int y = rect.Top; y < rect.Bottom; y++) { for (int x = rect.Left; x < rect.Right; x++) { if (selectionRegion.IsVisible(x, y)) { CurrentPixel = src[x,y]; ColorBgra CurrentPixel2 = src[x,y]; r=mr; g=mg; b=mb; mr+=CurrentPixel2.R; mg+=CurrentPixel2.G; mb+=CurrentPixel2.B; CurrentPixel2.R=(byte)r; CurrentPixel2.G=(byte)g; CurrentPixel2.B=(byte)b; r=CurrentPixel2.R; g=CurrentPixel2.G; b=CurrentPixel2.B; r2=CurrentPixel.R; g2=CurrentPixel.G; b2=CurrentPixel.B; m=((r2*(100-Amount3)+(r*Amount3))/100); CurrentPixel.R=(byte)m; m=((g2*(100-Amount3)+(g*Amount3))/100); CurrentPixel.G=(byte)m; m=((b2*(100-Amount3)+(b*Amount3))/100); CurrentPixel.B=(byte)m; dst[x,y] = CurrentPixel; if (Amount1==0){ m=(int)((CurrentPixel.R+CurrentPixel.G+CurrentPixel.B)/3); m+=Amount2; m+=1; m2=512/m; m3=m/m2; m=(int)(m/m2); if (m==m3){ CurrentPixel.R=255;CurrentPixel.G=255;CurrentPixel.B=255;}else {CurrentPixel.R=0;CurrentPixel.B=0;CurrentPixel.G=0;}} if (Amount1==1){ m=(int)CurrentPixel.R; m+=Amount2; m+=1; m2=512/m; m3=m/m2; m=(int)(m/m2); if (m==m3){ CurrentPixel.R=255;}else {CurrentPixel.R=0;} m=(int)CurrentPixel.G; m+=Amount2; m+=1; m2=512/m; m3=m/m2; m=(int)(m/m2); if (m==m3){ CurrentPixel.G=255;}else {CurrentPixel.G=0;} m=(int)CurrentPixel.B; m+=Amount2; m+=1; m2=512/m; m3=m/m2; m=(int)(m/m2); if (m==m3){ CurrentPixel.B=255;}else {CurrentPixel.B=0;} } dst[x,y] = CurrentPixel; } } } }
-
How was your vacation?
whoohoo ts rail
-
thanks for telling me. I fixed it now, and added a icon:
http://rapidshare.com/files/49636134/monochrome.dll.html
(I have my reasons for not sharing the source code.)
-
I saw some requests for it on the forum, and I happened make one already after experimenting a bit with Codeab.
it has got 2 modes, one for black/white, and the other for color (= black/white/red/green/blue/cyan/magenta/yellow)
normally if you use this effect on an photo, it will be dithered.
if you use it on a simple graphic (like an icon, or something made with ms paint.) it will not dither.
(dither slider should only be used on blurry photos)
example:
(black/white)
(color)
Spoiler// Name: Monochrome // Author: hollander #region UICode RadioButtonControl Amount1 = 0; // [1] Mode|Black and White|Color IntSliderControl Amount2 = 128; // [0,255,5] Brightness IntSliderControl Amount3 = 0; // [0,100] Dither #endregion void Render(Surface dst, Surface src, Rectangle rect) { ColorBgra CurrentPixel; ColorBgra CurrentPixel2; int m; float m2; float m3; int r; int g; int b; int r2; int g2; int b2; int mr = 124; int mg = 872; int mb = 164; for (int y = rect.Top; y < rect.Bottom; y++) { if (IsCancelRequested) return; for (int x = rect.Left; x < rect.Right; x++) { CurrentPixel = src[x, y]; CurrentPixel2 = src[x, y]; r = mr; g = mg; b = mb; mr += CurrentPixel2.R; mg += CurrentPixel2.G; mb += CurrentPixel2.B; CurrentPixel2.R = (byte)r; CurrentPixel2.G = (byte)g; CurrentPixel2.B = (byte)b; r = CurrentPixel2.R; g = CurrentPixel2.G; b = CurrentPixel2.B; r2 = CurrentPixel.R; g2 = CurrentPixel.G; b2 = CurrentPixel.B; m = ((r2 * (100 - Amount3) + (r * Amount3)) / 100); CurrentPixel.R = (byte)m; m = ((g2 * (100 - Amount3) + (g * Amount3)) / 100); CurrentPixel.G = (byte)m; m = ((b2 * (100 - Amount3) + (b * Amount3)) / 100); CurrentPixel.B = (byte)m; if (Amount1 == 0) { m = (int)((CurrentPixel.R + CurrentPixel.G + CurrentPixel.B) / 3); m += Amount2; m += 1; m2 = 512 / m; m3 = m / m2; m = (int)(m / m2); if (m == m3) { CurrentPixel.R = 255; CurrentPixel.G = 255; CurrentPixel.B = 255; } else { CurrentPixel.R = 0; CurrentPixel.B = 0; CurrentPixel.G = 0; } } else { m = (int)CurrentPixel.R; m += Amount2; m += 1; m2 = 512 / m; m3 = m / m2; m = (int)(m / m2); if (m == m3) { CurrentPixel.R = 255; } else { CurrentPixel.R = 0; } m = (int)CurrentPixel.G; m += Amount2; m += 1; m2 = 512 / m; m3 = m / m2; m = (int)(m / m2); if (m == m3) { CurrentPixel.G = 255; } else { CurrentPixel.G = 0; } m = (int)CurrentPixel.B; m += Amount2; m += 1; m2 = 512 / m; m3 = m / m2; m = (int)(m / m2); if (m == m3) { CurrentPixel.B = 255; } else { CurrentPixel.B = 0; } } dst[x, y] = CurrentPixel; } } }
-
-
Hey, boltbait (and Rick), isn't the:
...selectionRegion.IsVisible(x, y)...
stuff supposed to be unnecessary?
I've seen a bit of back-n-forth on that point, but don't think I ever saw a definitive answer.
I already removed that part from all the scripts now
-
(english isnt my first language, so sorry if there are anny spelling errors.)
I will explain how to make some simple effects using codelab. (if you are an expierenced codelab-user, you probably wont need this tutorial.)
I will explain: invert colors, saturation,brightness and contrast
to make a plugin using codelab you will need ...........Codelab
so just a few notes first: to write a plugin you will need to understand c#, but just te basics really. (the basics of c++ will work fine aswell.)
also you will need to understand the RGBA system
now finnaly some coding, i will now explain the base structure of a plugin (it is the example you get when you press clear)
int Amount1=0; //[0,100]Slider 1 Description int Amount2=0; //[0,100]Slider 2 Description int Amount3=0; //[0,100]Slider 3 Description //Int Amount 1,2 and 3 will be values you can adjust using sliders when //compiled. //here you can define variables you are going to use, for example: //int variable; //float pi=3.14; void Render(Surface dst, Surface src, Rectangle rect) { PdnRegion selectionRegion = EnvironmentParameters.GetSelection(src.Bounds); //these codes are for getting some usefull variables, leave them //untouched, until compiling the script (they might be very handy for your script. Rectangle selection = this.EnvironmentParameters.GetSelection(src.Bounds).GetBoundsInt(); long CenterX = (long)(((selection.Right - selection.Left) / 2)+selection.Left); long CenterY = (long)(((selection.Bottom - selection.Top) / 2)+selection.Top); ColorBgra PrimaryColor = (ColorBgra)EnvironmentParameters.PrimaryColor; ColorBgra SecondaryColor = (ColorBgra)EnvironmentParameters.SecondaryColor; int BrushWidth = (int)EnvironmentParameters.BrushWidth; ColorBgra CurrentPixel; for(int y = rect.Top; y < rect.Bottom; y++) { for (int x = rect.Left; x < rect.Right; x++) { CurrentPixel = src[x,y]; //here come the main code, if you dont change the structure, it will scan //every pixel and modify is using the code you entered; //in this example we change every pixel into the primary color CurrentPixel.R = (byte)PrimaryColor.R; CurrentPixel.G = (byte)PrimaryColor.G; CurrentPixel.B = (byte)PrimaryColor.B; CurrentPixel.A = (byte)PrimaryColor.A; dst[x,y] = CurrentPixel; } } }
note that everything with // is a comment and wont be executed.
now that you understand the base structure we will be using, I will explain the first effect:
INVERT COLORS
to invert colors you should first know what invert actually is. it is changing the R,G and B values to the "inverted" values. it means a 0 will become a 255 and a 255 will become a 0, a 1 will become a 254 and a 254 will become a 1. Or simple: color=255-color. (its that simple)
so our code will be after a finishing touch:
void Render(Surface dst, Surface src, Rectangle rect) { PdnRegion selectionRegion = EnvironmentParameters.GetSelection(src.Bounds); ColorBgra CurrentPixel; for(int y = rect.Top; y < rect.Bottom; y++) { for (int x = rect.Left; x < rect.Right; x++) { CurrentPixel = src[x,y]; CurrentPixel.R = (byte)(int)(255-CurrentPixel.R); CurrentPixel.G = (byte)(int)(255-CurrentPixel.G); CurrentPixel.B = (byte)(int)(255-CurrentPixel.; //note that the alpha channel is not inverted. dst[x,y] = CurrentPixel; } } }
next up:
GRAYSCALE
Grayscale is also an easy one, when a picture is grayscale, the R,G and B channel are exactly the same. in the following example I will user the integer values r,g,b and m. I use these values so I can multiply, divide and so on. (wich is not posible with byte values). r,g an b will represent the r,g and b channels. m will be the average of the r,g an b values.
int r; int g; int b; int m; void Render(Surface dst, Surface src, Rectangle rect) { PdnRegion selectionRegion = EnvironmentParameters.GetSelection(src.Bounds); ColorBgra CurrentPixel; for(int y = rect.Top; y < rect.Bottom; y++) { for (int x = rect.Left; x < rect.Right; x++) { CurrentPixel = src[x,y]; r=CurrentPixel.R; g=CurrentPixel.G; b=CurrentPixel.B; m=(r+g+b)/3; CurrentPixel.R = (byte)(int)m; CurrentPixel.G = (byte)(int)m; CurrentPixel.B = (byte)(int)m; dst[x,y] = CurrentPixel; } } }
next up:
SATURNATION
in normal words: how much "color" you image will have. if saturation is set to 100, nothing will change, if set to 0 the image will be grayscale, if set to 200, the image will be twice are colorful.
note: if you want to see result without compiling right away, just change the valea of Amount1 in the first line
int Amount1=100; //[0,100]Slider 1 Description int r; int g; int b; int m; void Render(Surface dst, Surface src, Rectangle rect) { PdnRegion selectionRegion = EnvironmentParameters.GetSelection(src.Bounds); ColorBgra CurrentPixel; for(int y = rect.Top; y < rect.Bottom; y++) { for (int x = rect.Left; x < rect.Right; x++) { CurrentPixel = src[x,y]; r=CurrentPixel.R; g=CurrentPixel.G; b=CurrentPixel.B; m=(r+g+b)/3; r-=m; g-=m; b-=m; r=m+r*(Amount1/100); g=m+g*(Amount1/100); b=m+b*(Amount1/100); //these codes are very important, if you dont use the you will get an ugly result: if (r>255){r=255;}if (r<0){r=0;} if (g>255){g=255;}if (g<0){g=0;} if (b>255){b=255;}if (b<0){b=0;} CurrentPixel.R = (byte)(int)r; CurrentPixel.G = (byte)(int)g; CurrentPixel.B = (byte)(int)b; dst[x,y] = CurrentPixel; } } }
BRIGHTNESS
very simple, the lower the rgb values are, the darker and image is, the higher, the lighter an image is:
int Amount1=0; //[-255,255]Slider 1 Description int r; int g; int b; int m; void Render(Surface dst, Surface src, Rectangle rect) { PdnRegion selectionRegion = EnvironmentParameters.GetSelection(src.Bounds); ColorBgra CurrentPixel; for(int y = rect.Top; y < rect.Bottom; y++) { for (int x = rect.Left; x < rect.Right; x++) { CurrentPixel = src[x,y]; r=CurrentPixel.R; g=CurrentPixel.G; b=CurrentPixel.B; r+=Amount1; g+=Amount1; b+=Amount1; if (r>255){r=255;}if (r<0){r=0;} if (g>255){g=255;}if (g<0){g=0;} if (b>255){b=255;}if (b<0){b=0;} CurrentPixel.R = (byte)(int)r; CurrentPixel.G = (byte)(int)g; CurrentPixel.B = (byte)(int)b; dst[x,y] = CurrentPixel; } } }
CONTRAST
it simply is the diference between dark and light colors, if set to the minumum a picture will become grey, if set to the maximum a picture will become black and white
int Amount1=100; //[0,1000]Slider 1 Description int r; int g; int b; int m; void Render(Surface dst, Surface src, Rectangle rect) { PdnRegion selectionRegion = EnvironmentParameters.GetSelection(src.Bounds); ColorBgra CurrentPixel; for(int y = rect.Top; y < rect.Bottom; y++) { for (int x = rect.Left; x < rect.Right; x++) { CurrentPixel = src[x,y]; r=CurrentPixel.R; g=CurrentPixel.G; b=CurrentPixel.B; m=(r+g+b)/3; r-=m; g-=m; b-=m; m-=128; m=m*(Amount1/100); m+=128; r+=m; g+=m; b+=m; if (r>255){r=255;}if (r<0){r=0;} if (g>255){g=255;}if (g<0){g=0;} if (b>255){b=255;}if (b<0){b=0;} CurrentPixel.R = (byte)(int)r; CurrentPixel.G = (byte)(int)g; CurrentPixel.B = (byte)(int)b; dst[x,y] = CurrentPixel; } } }
MY VERSION OF CONTRAST
(it uses contrast on each channel seperately)
int Amount1=100; //[0,1000]Slider 1 Description int r; int g; int b; int m; void Render(Surface dst, Surface src, Rectangle rect) { PdnRegion selectionRegion = EnvironmentParameters.GetSelection(src.Bounds); ColorBgra CurrentPixel; for(int y = rect.Top; y < rect.Bottom; y++) { for (int x = rect.Left; x < rect.Right; x++) { CurrentPixel = src[x,y]; r=CurrentPixel.R; g=CurrentPixel.G; b=CurrentPixel.B; r-=128; r=r*(Amount1/100); r+=128; g-=128; g=g*(Amount1/100); g+=128; b-=128; b=b*(Amount1/100); b+=128; if (r>255){r=255;}if (r<0){r=0;} if (g>255){g=255;}if (g<0){g=0;} if (b>255){b=255;}if (b<0){b=0;} CurrentPixel.R = (byte)(int)r; CurrentPixel.G = (byte)(int)g; CurrentPixel.B = (byte)(int)b; dst[x,y] = CurrentPixel; } } }
I hope this will heb beginning codelabbers.
(I tested all scripts, they all work.)
The Pictorium! Post your created or edited images here!
in The Pictorium
Posted
I use it as my background now.