diff --git a/README.md b/README.md index 73cfdffe7..377d1c949 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,7 @@ git clone https://github.com/JimBobSquarePants/ImageProcessor - [x] Rectangle - [x] Size - [x] Point - - [ ] Sphere + - [ ] Ellipse - Resampling algorithms. (Performance improvements?) - [x] Box - [x] Bicubic @@ -77,7 +77,7 @@ git clone https://github.com/JimBobSquarePants/ImageProcessor - Cropping - [x] Rectangular Crop - [ ] Elliptical Crop - - [ ] Entropy Crop + - [x] Entropy Crop - Rotation - [ ] Flip (90, 270, FlipType etc. Need help) - [ ] Rotate by angle (Need help) @@ -109,6 +109,7 @@ git clone https://github.com/JimBobSquarePants/ImageProcessor - [x] Invert - [x] BackgroundColor - [x] Brightness + - [x] Pixelate - [x] Saturation - [ ] Hue - [x] Blend diff --git a/src/ImageProcessor/Colors/ColorDefinitions.cs b/src/ImageProcessor/Colors/ColorDefinitions.cs index cc5691940..af697051f 100644 --- a/src/ImageProcessor/Colors/ColorDefinitions.cs +++ b/src/ImageProcessor/Colors/ColorDefinitions.cs @@ -25,7 +25,7 @@ namespace ImageProcessor /// /// Represents a matching the W3C definition that has an hex value of #7FFFD4. /// - public static readonly Color AquaMarine = new Color(127 / 255f, 1, 212 / 255f); + public static readonly Color Aquamarine = new Color(127 / 255f, 1, 212 / 255f); /// /// Represents a matching the W3C definition that has an hex value of #F0FFFF. @@ -47,75 +47,669 @@ namespace ImageProcessor /// public static readonly Color Black = new Color(0, 0, 0); + /// + /// Represents a matching the W3C definition that has an hex value of #FFEBCD. + /// + public static readonly Color BlanchedAlmond = new Color(1, 235 / 255f, 205 / 255f); + /// /// Represents a matching the W3C definition that has an hex value of #0000FF. /// public static readonly Color Blue = new Color(0, 0, 1); /// - /// Represents a matching the W3C definition that has an hex value of #C0C0C0. + /// Represents a matching the W3C definition that has an hex value of #8A2BE2. /// - public static readonly Color Silver = new Color(192 / 255f, 192 / 255f, 192 / 255f); + public static readonly Color BlueViolet = new Color(138 / 255f, 43 / 255f, 226 / 255f); /// - /// Represents a matching the W3C definition that has an hex value of #808080. + /// Represents a matching the W3C definition that has an hex value of #A52A2A. /// - public static readonly Color Gray = new Color(128 / 255f, 128 / 255f, 128 / 255f); + public static readonly Color Brown = new Color(165 / 255f, 42 / 255f, 42 / 255f); /// - /// Represents a matching the W3C definition that has an hex value of #FFFFFF. + /// Represents a matching the W3C definition that has an hex value of #DEB887. /// - public static readonly Color White = new Color(1, 1, 1); + public static readonly Color BurlyWood = new Color(222 / 255f, 184 / 255f, 135 / 255f); /// - /// Represents a matching the W3C definition that has an hex value of #800000. + /// Represents a matching the W3C definition that has an hex value of #5F9EA0. /// - public static readonly Color Maroon = new Color(128 / 255f, 0, 0); + public static readonly Color CadetBlue = new Color(95 / 255f, 158 / 255f, 160 / 255f); /// - /// Represents a matching the W3C definition that has an hex value of #FF0000. + /// Represents a matching the W3C definition that has an hex value of #7FFF00. /// - public static readonly Color Red = new Color(1, 0, 0); + public static readonly Color Chartreuse = new Color(127 / 255f, 1, 0); /// - /// Represents a matching the W3C definition that has an hex value of #800080. + /// Represents a matching the W3C definition that has an hex value of #D2691E. /// - public static readonly Color Purple = new Color(128 / 255f, 0, 128 / 255f); + public static readonly Color Chocolate = new Color(210 / 255f, 105 / 255f, 30 / 255f); + + /// + /// Represents a matching the W3C definition that has an hex value of #FF7F50. + /// + public static readonly Color Coral = new Color(1, 127 / 255f, 80 / 255f); + + /// + /// Represents a matching the W3C definition that has an hex value of #6495ED. + /// + public static readonly Color CornflowerBlue = new Color(100 / 255f, 149 / 255f, 237 / 255f); + + /// + /// Represents a matching the W3C definition that has an hex value of #FFF8DC. + /// + public static readonly Color Cornsilk = new Color(1, 248 / 255f, 220 / 255f); + + /// + /// Represents a matching the W3C definition that has an hex value of #DC143C. + /// + public static readonly Color Crimson = new Color(220 / 255f, 20 / 255f, 60 / 255f); + + /// + /// Represents a matching the W3C definition that has an hex value of #00FFFF. + /// + public static readonly Color Cyan = new Color(0, 1, 1); + + /// + /// Represents a matching the W3C definition that has an hex value of #00008B. + /// + public static readonly Color DarkBlue = new Color(0, 0, 139 / 255f); + + /// + /// Represents a matching the W3C definition that has an hex value of #008B8B. + /// + public static readonly Color DarkCyan = new Color(0, 139 / 255f, 139 / 255f); + + /// + /// Represents a matching the W3C definition that has an hex value of #B8860B. + /// + public static readonly Color DarkGoldenrod = new Color(184 / 255f, 134 / 255f, 11 / 255f); + + /// + /// Represents a matching the W3C definition that has an hex value of #A9A9A9. + /// + public static readonly Color DarkGray = new Color(169 / 255f, 169 / 255f, 169 / 255f); + + /// + /// Represents a matching the W3C definition that has an hex value of #006400. + /// + public static readonly Color DarkGreen = new Color(0, 100 / 255f, 0); + + /// + /// Represents a matching the W3C definition that has an hex value of #BDB76B. + /// + public static readonly Color DarkKhaki = new Color(189 / 255f, 183 / 255f, 107 / 255f); + + /// + /// Represents a matching the W3C definition that has an hex value of #8B008B. + /// + public static readonly Color DarkMagenta = new Color(139 / 255f, 0, 139 / 255f); + + /// + /// Represents a matching the W3C definition that has an hex value of #556B2F. + /// + public static readonly Color DarkOliveGreen = new Color(85 / 255f, 107 / 255f, 47 / 255f); + + /// + /// Represents a matching the W3C definition that has an hex value of #FF8C00. + /// + public static readonly Color DarkOrange = new Color(1, 140 / 255f, 0); + + /// + /// Represents a matching the W3C definition that has an hex value of #9932CC. + /// + public static readonly Color DarkOrchid = new Color(153 / 255f, 50 / 255f, 204 / 255f); + + /// + /// Represents a matching the W3C definition that has an hex value of #8B0000. + /// + public static readonly Color DarkRed = new Color(139 / 255f, 0, 0); + + /// + /// Represents a matching the W3C definition that has an hex value of #E9967A. + /// + public static readonly Color DarkSalmon = new Color(233 / 255f, 150 / 255f, 122 / 255f); + + /// + /// Represents a matching the W3C definition that has an hex value of #8FBC8B. + /// + public static readonly Color DarkSeaGreen = new Color(143 / 255f, 188 / 255f, 139 / 255f); + + /// + /// Represents a matching the W3C definition that has an hex value of #483D8B. + /// + public static readonly Color DarkSlateBlue = new Color(72 / 255f, 61 / 255f, 139 / 255f); + + /// + /// Represents a matching the W3C definition that has an hex value of #2F4F4F. + /// + public static readonly Color DarkSlateGray = new Color(47 / 255f, 79 / 255f, 79 / 255f); + + /// + /// Represents a matching the W3C definition that has an hex value of #00CED1. + /// + public static readonly Color DarkTurquoise = new Color(0, 206 / 255f, 209 / 255f); + + /// + /// Represents a matching the W3C definition that has an hex value of #9400D3. + /// + public static readonly Color DarkViolet = new Color(148 / 255f, 0, 211 / 255f); + + /// + /// Represents a matching the W3C definition that has an hex value of #FF1493. + /// + public static readonly Color DeepPink = new Color(1, 20 / 255f, 147 / 255f); + + /// + /// Represents a matching the W3C definition that has an hex value of #00BFFF. + /// + public static readonly Color DeepSkyBlue = new Color(0, 191 / 255f, 1); + + /// + /// Represents a matching the W3C definition that has an hex value of #696969. + /// + public static readonly Color DimGray = new Color(105 / 255f, 105 / 255f, 105 / 255f); + + /// + /// Represents a matching the W3C definition that has an hex value of #1E90FF. + /// + public static readonly Color DodgerBlue = new Color(30 / 255f, 144 / 255f, 1); + + /// + /// Represents a matching the W3C definition that has an hex value of #B22222. + /// + public static readonly Color Firebrick = new Color(178 / 255f, 34 / 255f, 34 / 255f); + + /// + /// Represents a matching the W3C definition that has an hex value of #FFFAF0. + /// + public static readonly Color FloralWhite = new Color(1, 250 / 255f, 240 / 255f); + + /// + /// Represents a matching the W3C definition that has an hex value of #228B22. + /// + public static readonly Color ForestGreen = new Color(34 / 255f, 139 / 255f, 34 / 255f); /// /// Represents a matching the W3C definition that has an hex value of #FF00FF. /// public static readonly Color Fuchsia = new Color(1, 0, 1); + /// + /// Represents a matching the W3C definition that has an hex value of #DCDCDC. + /// + public static readonly Color Gainsboro = new Color(220 / 255f, 220 / 255f, 220 / 255f); + + /// + /// Represents a matching the W3C definition that has an hex value of #F8F8FF. + /// + public static readonly Color GhostWhite = new Color(248 / 255f, 248 / 255f, 1); + + /// + /// Represents a matching the W3C definition that has an hex value of #FFD700. + /// + public static readonly Color Gold = new Color(1, 215 / 255f, 0); + + /// + /// Represents a matching the W3C definition that has an hex value of #DAA520. + /// + public static readonly Color Goldenrod = new Color(218 / 255f, 165 / 255f, 32 / 255f); + + /// + /// Represents a matching the W3C definition that has an hex value of #808080. + /// + public static readonly Color Gray = new Color(128 / 255f, 128 / 255f, 128 / 255f); + /// /// Represents a matching the W3C definition that has an hex value of #008000. /// public static readonly Color Green = new Color(0, 128 / 255f, 0); + /// + /// Represents a matching the W3C definition that has an hex value of #ADFF2F. + /// + public static readonly Color GreenYellow = new Color(173 / 255f, 1, 47 / 255f); + + /// + /// Represents a matching the W3C definition that has an hex value of #F0FFF0. + /// + public static readonly Color Honeydew = new Color(240 / 255f, 1, 240 / 255f); + + /// + /// Represents a matching the W3C definition that has an hex value of #FF69B4. + /// + public static readonly Color HotPink = new Color(1, 105 / 255f, 180 / 255f); + + /// + /// Represents a matching the W3C definition that has an hex value of #CD5C5C. + /// + public static readonly Color IndianRed = new Color(205 / 255f, 92 / 255f, 92 / 255f); + + /// + /// Represents a matching the W3C definition that has an hex value of #4B0082. + /// + public static readonly Color Indigo = new Color(75 / 255f, 0, 130 / 255f); + + /// + /// Represents a matching the W3C definition that has an hex value of #FFFFF0. + /// + public static readonly Color Ivory = new Color(1, 1, 240 / 255f); + + /// + /// Represents a matching the W3C definition that has an hex value of #F0E68C. + /// + public static readonly Color Khaki = new Color(240 / 255f, 230 / 255f, 140 / 255f); + + /// + /// Represents a matching the W3C definition that has an hex value of #E6E6FA. + /// + public static readonly Color Lavender = new Color(230 / 255f, 230 / 255f, 250 / 255f); + + /// + /// Represents a matching the W3C definition that has an hex value of #FFF0F5. + /// + public static readonly Color LavenderBlush = new Color(1, 240 / 255f, 245 / 255f); + + /// + /// Represents a matching the W3C definition that has an hex value of #7CFC00. + /// + public static readonly Color LawnGreen = new Color(124 / 255f, 252 / 255f, 0); + + /// + /// Represents a matching the W3C definition that has an hex value of #FFFACD. + /// + public static readonly Color LemonChiffon = new Color(1, 250 / 255f, 205 / 255f); + + /// + /// Represents a matching the W3C definition that has an hex value of #ADD8E6. + /// + public static readonly Color LightBlue = new Color(173 / 255f, 216 / 255f, 230 / 255f); + + /// + /// Represents a matching the W3C definition that has an hex value of #F08080. + /// + public static readonly Color LightCoral = new Color(240 / 255f, 128 / 255f, 128 / 255f); + + /// + /// Represents a matching the W3C definition that has an hex value of #E0FFFF. + /// + public static readonly Color LightCyan = new Color(224 / 255f, 1, 1); + + /// + /// Represents a matching the W3C definition that has an hex value of #FAFAD2. + /// + public static readonly Color LightGoldenrodYellow = new Color(250 / 255f, 250 / 255f, 210 / 255f); + + /// + /// Represents a matching the W3C definition that has an hex value of #90EE90. + /// + public static readonly Color LightGreen = new Color(144 / 255f, 238 / 255f, 144 / 255f); + + /// + /// Represents a matching the W3C definition that has an hex value of #D3D3D3. + /// + public static readonly Color LightGray = new Color(211 / 255f, 211 / 255f, 211 / 255f); + + /// + /// Represents a matching the W3C definition that has an hex value of #FFB6C1. + /// + public static readonly Color LightPink = new Color(1, 182 / 255f, 193 / 255f); + + /// + /// Represents a matching the W3C definition that has an hex value of #FFA07A. + /// + public static readonly Color LightSalmon = new Color(1, 160 / 255f, 122 / 255f); + + /// + /// Represents a matching the W3C definition that has an hex value of #20B2AA. + /// + public static readonly Color LightSeaGreen = new Color(32 / 255f, 178 / 255f, 170 / 255f); + + /// + /// Represents a matching the W3C definition that has an hex value of #87CEFA. + /// + public static readonly Color LightSkyBlue = new Color(135 / 255f, 206 / 255f, 250 / 255f); + + /// + /// Represents a matching the W3C definition that has an hex value of #778899. + /// + public static readonly Color LightSlateGray = new Color(119 / 255f, 136 / 255f, 153 / 255f); + + /// + /// Represents a matching the W3C definition that has an hex value of #B0C4DE. + /// + public static readonly Color LightSteelBlue = new Color(176 / 255f, 196 / 255f, 222 / 255f); + + /// + /// Represents a matching the W3C definition that has an hex value of #FFFFE0. + /// + public static readonly Color LightYellow = new Color(1, 1, 224 / 255f); + /// /// Represents a matching the W3C definition that has an hex value of #00FF00. /// public static readonly Color Lime = new Color(0, 1, 0); /// - /// Represents a matching the W3C definition that has an hex value of #808000. + /// Represents a matching the W3C definition that has an hex value of #32CD32. /// - public static readonly Color Olive = new Color(128 / 255f, 128 / 255f, 0); + public static readonly Color LimeGreen = new Color(50 / 255f, 205 / 255f, 50 / 255f); /// - /// Represents a matching the W3C definition that has an hex value of #FFFF00. + /// Represents a matching the W3C definition that has an hex value of #FAF0E6. /// - public static readonly Color Yellow = new Color(1, 1, 0); + public static readonly Color Linen = new Color(250 / 255f, 240 / 255f, 230 / 255f); + + /// + /// Represents a matching the W3C definition that has an hex value of #FF00FF. + /// + public static readonly Color Magenta = new Color(1, 0, 1); + + /// + /// Represents a matching the W3C definition that has an hex value of #800000. + /// + public static readonly Color Maroon = new Color(128 / 255f, 0, 0); + + /// + /// Represents a matching the W3C definition that has an hex value of #66CDAA. + /// + public static readonly Color MediumAquamarine = new Color(102 / 255f, 205 / 255f, 170 / 255f); + + /// + /// Represents a matching the W3C definition that has an hex value of #0000CD. + /// + public static readonly Color MediumBlue = new Color(0, 0, 205 / 255f); + + /// + /// Represents a matching the W3C definition that has an hex value of #BA55D3. + /// + public static readonly Color MediumOrchid = new Color(186 / 255f, 85 / 255f, 211 / 255f); + + /// + /// Represents a matching the W3C definition that has an hex value of #9370DB. + /// + public static readonly Color MediumPurple = new Color(147 / 255f, 112 / 255f, 219 / 255f); + + /// + /// Represents a matching the W3C definition that has an hex value of #3CB371. + /// + public static readonly Color MediumSeaGreen = new Color(60 / 255f, 179 / 255f, 113 / 255f); + + /// + /// Represents a matching the W3C definition that has an hex value of #7B68EE. + /// + public static readonly Color MediumSlateBlue = new Color(123 / 255f, 104 / 255f, 238 / 255f); + + /// + /// Represents a matching the W3C definition that has an hex value of #00FA9A. + /// + public static readonly Color MediumSpringGreen = new Color(0, 250 / 255f, 154 / 255f); + + /// + /// Represents a matching the W3C definition that has an hex value of #48D1CC. + /// + public static readonly Color MediumTurquoise = new Color(72 / 255f, 209 / 255f, 204 / 255f); + + /// + /// Represents a matching the W3C definition that has an hex value of #C71585. + /// + public static readonly Color MediumVioletRed = new Color(199 / 255f, 21 / 255f, 133 / 255f); + + /// + /// Represents a matching the W3C definition that has an hex value of #191970. + /// + public static readonly Color MidnightBlue = new Color(25 / 255f, 25 / 255f, 112 / 255f); + + /// + /// Represents a matching the W3C definition that has an hex value of #F5FFFA. + /// + public static readonly Color MintCream = new Color(245 / 255f, 1, 250 / 255f); + + /// + /// Represents a matching the W3C definition that has an hex value of #FFE4E1. + /// + public static readonly Color MistyRose = new Color(1, 228 / 255f, 225 / 255f); + + /// + /// Represents a matching the W3C definition that has an hex value of #FFE4B5. + /// + public static readonly Color Moccasin = new Color(1, 228 / 255f, 181 / 255f); + + /// + /// Represents a matching the W3C definition that has an hex value of #FFDEAD. + /// + public static readonly Color NavajoWhite = new Color(1, 222 / 255f, 173 / 255f); /// /// Represents a matching the W3C definition that has an hex value of #000080. /// public static readonly Color Navy = new Color(0, 0, 128 / 255f); + /// + /// Represents a matching the W3C definition that has an hex value of #FDF5E6. + /// + public static readonly Color OldLace = new Color(253 / 255f, 245 / 255f, 230 / 255f); + + /// + /// Represents a matching the W3C definition that has an hex value of #808000. + /// + public static readonly Color Olive = new Color(128 / 255f, 128 / 255f, 0); + + /// + /// Represents a matching the W3C definition that has an hex value of #6B8E23. + /// + public static readonly Color OliveDrab = new Color(107 / 255f, 142 / 255f, 35 / 255f); + + /// + /// Represents a matching the W3C definition that has an hex value of #FFA500. + /// + public static readonly Color Orange = new Color(1, 165 / 255f, 0); + + /// + /// Represents a matching the W3C definition that has an hex value of #FF4500. + /// + public static readonly Color OrangeRed = new Color(1, 69 / 255f, 0); + + /// + /// Represents a matching the W3C definition that has an hex value of #DA70D6. + /// + public static readonly Color Orchid = new Color(218 / 255f, 112 / 255f, 214 / 255f); + + /// + /// Represents a matching the W3C definition that has an hex value of #EEE8AA. + /// + public static readonly Color PaleGoldenrod = new Color(238 / 255f, 232 / 255f, 170 / 255f); + + /// + /// Represents a matching the W3C definition that has an hex value of #98FB98. + /// + public static readonly Color PaleGreen = new Color(152 / 255f, 251 / 255f, 152 / 255f); + + /// + /// Represents a matching the W3C definition that has an hex value of #AFEEEE. + /// + public static readonly Color PaleTurquoise = new Color(175 / 255f, 238 / 255f, 238 / 255f); + + /// + /// Represents a matching the W3C definition that has an hex value of #DB7093. + /// + public static readonly Color PaleVioletRed = new Color(219 / 255f, 112 / 255f, 147 / 255f); + + /// + /// Represents a matching the W3C definition that has an hex value of #FFEFD5. + /// + public static readonly Color PapayaWhip = new Color(1, 239 / 255f, 213 / 255f); + + /// + /// Represents a matching the W3C definition that has an hex value of #FFDAB9. + /// + public static readonly Color PeachPuff = new Color(1, 218 / 255f, 185 / 255f); + + /// + /// Represents a matching the W3C definition that has an hex value of #CD853F. + /// + public static readonly Color Peru = new Color(205 / 255f, 133 / 255f, 63 / 255f); + + /// + /// Represents a matching the W3C definition that has an hex value of #FFC0CB. + /// + public static readonly Color Pink = new Color(1, 192 / 255f, 203 / 255f); + + /// + /// Represents a matching the W3C definition that has an hex value of #DDA0DD. + /// + public static readonly Color Plum = new Color(221 / 255f, 160 / 255f, 221 / 255f); + + /// + /// Represents a matching the W3C definition that has an hex value of #B0E0E6. + /// + public static readonly Color PowderBlue = new Color(176 / 255f, 224 / 255f, 230 / 255f); + + /// + /// Represents a matching the W3C definition that has an hex value of #800080. + /// + public static readonly Color Purple = new Color(128 / 255f, 0, 128 / 255f); + + /// + /// Represents a matching the W3C definition that has an hex value of #663399. + /// + public static readonly Color RebeccaPurple = new Color(102 / 255f, 51 / 255f, 153 / 255f); + + /// + /// Represents a matching the W3C definition that has an hex value of #FF0000. + /// + public static readonly Color Red = new Color(1, 0, 0); + + /// + /// Represents a matching the W3C definition that has an hex value of #BC8F8F. + /// + public static readonly Color RosyBrown = new Color(188 / 255f, 143 / 255f, 143 / 255f); + + /// + /// Represents a matching the W3C definition that has an hex value of #4169E1. + /// + public static readonly Color RoyalBlue = new Color(65 / 255f, 105 / 255f, 225 / 255f); + + /// + /// Represents a matching the W3C definition that has an hex value of #8B4513. + /// + public static readonly Color SaddleBrown = new Color(139 / 255f, 69 / 255f, 19 / 255f); + + /// + /// Represents a matching the W3C definition that has an hex value of #FA8072. + /// + public static readonly Color Salmon = new Color(250 / 255f, 128 / 255f, 114 / 255f); + + /// + /// Represents a matching the W3C definition that has an hex value of #F4A460. + /// + public static readonly Color SandyBrown = new Color(244 / 255f, 164 / 255f, 96 / 255f); + + /// + /// Represents a matching the W3C definition that has an hex value of #2E8B57. + /// + public static readonly Color SeaGreen = new Color(46 / 255f, 139 / 255f, 87 / 255f); + + /// + /// Represents a matching the W3C definition that has an hex value of #FFF5EE. + /// + public static readonly Color SeaShell = new Color(1, 245 / 255f, 238 / 255f); + + /// + /// Represents a matching the W3C definition that has an hex value of #A0522D. + /// + public static readonly Color Sienna = new Color(160 / 255f, 82 / 255f, 45 / 255f); + + /// + /// Represents a matching the W3C definition that has an hex value of #C0C0C0. + /// + public static readonly Color Silver = new Color(192 / 255f, 192 / 255f, 192 / 255f); + + /// + /// Represents a matching the W3C definition that has an hex value of #87CEEB. + /// + public static readonly Color SkyBlue = new Color(135 / 255f, 206 / 255f, 235 / 255f); + + /// + /// Represents a matching the W3C definition that has an hex value of #6A5ACD. + /// + public static readonly Color SlateBlue = new Color(106 / 255f, 90 / 255f, 205 / 255f); + + /// + /// Represents a matching the W3C definition that has an hex value of #708090. + /// + public static readonly Color SlateGray = new Color(112 / 255f, 128 / 255f, 144 / 255f); + + /// + /// Represents a matching the W3C definition that has an hex value of #FFFAFA. + /// + public static readonly Color Snow = new Color(1, 250 / 255f, 250 / 255f); + + /// + /// Represents a matching the W3C definition that has an hex value of #00FF7F. + /// + public static readonly Color SpringGreen = new Color(0, 1, 127 / 255f); + + /// + /// Represents a matching the W3C definition that has an hex value of #4682B4. + /// + public static readonly Color SteelBlue = new Color(70 / 255f, 130 / 255f, 180 / 255f); + + /// + /// Represents a matching the W3C definition that has an hex value of #D2B48C. + /// + public static readonly Color Tan = new Color(210 / 255f, 180 / 255f, 140 / 255f); + /// /// Represents a matching the W3C definition that has an hex value of #008080. /// public static readonly Color Teal = new Color(0, 128 / 255f, 128 / 255f); + /// + /// Represents a matching the W3C definition that has an hex value of #D8BFD8. + /// + public static readonly Color Thistle = new Color(216 / 255f, 191 / 255f, 216 / 255f); + + /// + /// Represents a matching the W3C definition that has an hex value of #FF6347. + /// + public static readonly Color Tomato = new Color(1, 99 / 255f, 71 / 255f); + + /// + /// Represents a matching the W3C definition that has an hex value of #40E0D0. + /// + public static readonly Color Turquoise = new Color(64 / 255f, 224 / 255f, 208 / 255f); + + /// + /// Represents a matching the W3C definition that has an hex value of #EE82EE. + /// + public static readonly Color Violet = new Color(238 / 255f, 130 / 255f, 238 / 255f); + + /// + /// Represents a matching the W3C definition that has an hex value of #F5DEB3. + /// + public static readonly Color Wheat = new Color(245 / 255f, 222 / 255f, 179 / 255f); + + /// + /// Represents a matching the W3C definition that has an hex value of #FFFFFF. + /// + public static readonly Color White = new Color(1, 1, 1); + + /// + /// Represents a matching the W3C definition that has an hex value of #F5F5F5. + /// + public static readonly Color WhiteSmoke = new Color(245 / 255f, 245 / 255f, 245 / 255f); + + /// + /// Represents a matching the W3C definition that has an hex value of #FFFF00. + /// + public static readonly Color Yellow = new Color(1, 1, 0); + + /// + /// Represents a matching the W3C definition that has an hex value of #9ACD32. + /// + public static readonly Color YellowGreen = new Color(154 / 255f, 205 / 255f, 50 / 255f); } } diff --git a/src/ImageProcessor/Common/Helpers/ImageMaths.cs b/src/ImageProcessor/Common/Helpers/ImageMaths.cs index 405b43d79..04689c2ec 100644 --- a/src/ImageProcessor/Common/Helpers/ImageMaths.cs +++ b/src/ImageProcessor/Common/Helpers/ImageMaths.cs @@ -240,6 +240,8 @@ namespace ImageProcessor { if (delegateFunc(imageBase, x, y, componentValue)) { + var c = imageBase[x, y]; + return y; } } diff --git a/src/ImageProcessor/Filters/Binarization/Threshold.cs b/src/ImageProcessor/Filters/Binarization/Threshold.cs index 71deaa25b..43e929bbc 100644 --- a/src/ImageProcessor/Filters/Binarization/Threshold.cs +++ b/src/ImageProcessor/Filters/Binarization/Threshold.cs @@ -10,8 +10,8 @@ namespace ImageProcessor.Filters /// /// An to perform binary threshold filtering against an - /// . The mage will be converted to greyscale before thresholding - /// occurrs. + /// . The image will be converted to greyscale before thresholding + /// occurs. /// public class Threshold : ParallelImageProcessor { diff --git a/src/ImageProcessor/Filters/ImageFilterExtensions.cs b/src/ImageProcessor/Filters/ImageFilterExtensions.cs index 81b096c85..ceaf47a34 100644 --- a/src/ImageProcessor/Filters/ImageFilterExtensions.cs +++ b/src/ImageProcessor/Filters/ImageFilterExtensions.cs @@ -301,6 +301,31 @@ namespace ImageProcessor.Filters return source.Process(rectangle, new Polaroid()); } + /// + /// Pixelates and image with the given pixel size. + /// + /// The image this method extends. + /// The size of the pixels. + /// The . + public static Image Pixelate(this Image source, int size = 4) + { + return source.Process(source.Bounds, new Pixelate(size)); + } + + /// + /// Pixelates and image with the given pixel size. + /// + /// The image this method extends. + /// The size of the pixels. + /// + /// The structure that specifies the portion of the image object to alter. + /// + /// The . + public static Image Pixelate(this Image source, int size, Rectangle rectangle) + { + return source.Process(rectangle, new Pixelate(size)); + } + /// /// Alters the saturation component of the image. /// diff --git a/src/ImageProcessor/Filters/Invert.cs b/src/ImageProcessor/Filters/Invert.cs index 198c0d1ae..3363c12a9 100644 --- a/src/ImageProcessor/Filters/Invert.cs +++ b/src/ImageProcessor/Filters/Invert.cs @@ -29,7 +29,6 @@ namespace ImageProcessor.Filters { for (int x = startX; x < endX; x++) { - // TODO: This doesn't work for gamma test images. Color color = source[x, y]; color.R = 1 - color.R; color.G = 1 - color.G; diff --git a/src/ImageProcessor/Filters/Pixelate.cs b/src/ImageProcessor/Filters/Pixelate.cs new file mode 100644 index 000000000..7f3b17674 --- /dev/null +++ b/src/ImageProcessor/Filters/Pixelate.cs @@ -0,0 +1,92 @@ +// +// Copyright (c) James Jackson-South and contributors. +// Licensed under the Apache License, Version 2.0. +// + +namespace ImageProcessor.Filters +{ + using System; + using System.Collections.Generic; + using System.Threading.Tasks; + + /// + /// An to invert the colors of an . + /// + public class Pixelate : ParallelImageProcessor + { + /// + /// Initializes a new instance of the class. + /// + /// The size of the pixels. Must be greater than 0. + /// + /// is less than 0 or equal to 0. + /// + public Pixelate(int size) + { + Guard.MustBeGreaterThan(size, 0, nameof(size)); + this.Value = size; + } + + /// + public override int Parallelism { get; set; } = 1; + + /// + /// Gets or the pixel size. + /// + public int Value { get; } + + /// + protected override void Apply(ImageBase target, ImageBase source, Rectangle targetRectangle, Rectangle sourceRectangle, int startY, int endY) + { + int sourceY = sourceRectangle.Y; + int sourceBottom = sourceRectangle.Bottom; + int startX = sourceRectangle.X; + int endX = sourceRectangle.Right; + int size = this.Value; + int offset = this.Value / 2; + + // Get the range on the y-plane to choose from. + IEnumerable range = EnumerableExtensions.SteppedRange(startY, i => i < endY, size); + + Parallel.ForEach( + range, + y => + { + if (y >= sourceY && y < sourceBottom) + { + for (int x = startX; x < endX; x += size) + { + + int offsetX = offset; + int offsetY = offset; + + // Make sure that the offset is within the boundary of the + // image. + while (y + offsetY >= sourceBottom) + { + offsetY--; + } + + while (x + offsetX >= endX) + { + offsetX--; + } + + // Get the pixel color in the centre of the soon to be pixelated area. + // ReSharper disable AccessToDisposedClosure + Color pixel = source[x + offsetX, y + offsetY]; + + // For each pixel in the pixelate size, set it to the centre color. + for (int l = y; l < y + size && l < sourceBottom; l++) + { + for (int k = x; k < x + size && k < endX; k++) + { + target[k, l] = pixel; + } + } + } + } + }); + } + } +} diff --git a/src/ImageProcessor/Samplers/EntropyCrop.cs b/src/ImageProcessor/Samplers/EntropyCrop.cs index f71067a64..e97be9b2c 100644 --- a/src/ImageProcessor/Samplers/EntropyCrop.cs +++ b/src/ImageProcessor/Samplers/EntropyCrop.cs @@ -16,6 +16,8 @@ namespace ImageProcessor.Samplers /// public class EntropyCrop : ParallelImageProcessor { + private Rectangle cropRectangle; + /// /// Initializes a new instance of the class. /// @@ -39,37 +41,36 @@ namespace ImageProcessor.Samplers { ImageBase temp = new Image(source.Width, source.Height); - // TODO: Should we detect edges on a grayscale image? - new Sobel() { Greyscale = true }.Apply(temp, source, sourceRectangle); + // Detect the edges. + new Sobel().Apply(temp, source, sourceRectangle); // Apply threshold binarization filter. new Threshold(.5f).Apply(temp, temp, sourceRectangle); // Search for the first white pixels Rectangle rectangle = ImageMaths.GetFilteredBoundingRectangle(temp, 0); - target.SetPixels(rectangle.Width, rectangle.Height, new float[rectangle.Width * rectangle.Height * 4]); + // Reset the target pixel to the correct size. + target.SetPixels(rectangle.Width, rectangle.Height, new float[rectangle.Width * rectangle.Height * 4]); + this.cropRectangle = rectangle; } /// protected override void Apply(ImageBase target, ImageBase source, Rectangle targetRectangle, Rectangle sourceRectangle, int startY, int endY) { - int targetY = targetRectangle.Y; - int targetBottom = targetRectangle.Height; + int targetY = this.cropRectangle.Y; int startX = targetRectangle.X; - int endX = targetRectangle.Width; + int targetX = this.cropRectangle.X; + int endX = this.cropRectangle.Width; Parallel.For( startY, endY, y => { - if (y >= targetY && y < targetBottom) + for (int x = startX; x < endX; x++) { - for (int x = startX; x < endX; x++) - { - target[x, y] = source[x, y]; - } + target[x, y] = source[x + targetX, y + targetY]; } }); } diff --git a/tests/ImageProcessor.Tests/Processors/Filters/FilterTests.cs b/tests/ImageProcessor.Tests/Processors/Filters/FilterTests.cs index 75508e3d3..f985ca4d0 100644 --- a/tests/ImageProcessor.Tests/Processors/Filters/FilterTests.cs +++ b/tests/ImageProcessor.Tests/Processors/Filters/FilterTests.cs @@ -38,7 +38,8 @@ namespace ImageProcessor.Tests //{ "Prewitt", new Prewitt() }, //{ "RobertsCross", new RobertsCross() }, //{ "Scharr", new Scharr() }, - { "Sobel", new Sobel {Greyscale = true} }, + //{ "Sobel", new Sobel {Greyscale = true} }, + { "Pixelate", new Pixelate(8) }, //{ "GuassianBlur", new GuassianBlur(10) }, //{ "GuassianSharpen", new GuassianSharpen(10) } }; diff --git a/tests/ImageProcessor.Tests/Processors/ProcessorTestBase.cs b/tests/ImageProcessor.Tests/Processors/ProcessorTestBase.cs index f7e848dfe..d4d968f34 100644 --- a/tests/ImageProcessor.Tests/Processors/ProcessorTestBase.cs +++ b/tests/ImageProcessor.Tests/Processors/ProcessorTestBase.cs @@ -20,7 +20,7 @@ namespace ImageProcessor.Tests public static readonly List Files = new List { //"TestImages/Formats/Jpg/Backdrop.jpg", - //"TestImages/Formats/Jpg/Calliphora.jpg", + "TestImages/Formats/Jpg/Calliphora.jpg", //"TestImages/Formats/Jpg/china.jpg", //"TestImages/Formats/Jpg/ant.jpg", //"TestImages/Formats/Jpg/parachute.jpg", diff --git a/tests/ImageProcessor.Tests/Processors/Samplers/SamplerTests.cs b/tests/ImageProcessor.Tests/Processors/Samplers/SamplerTests.cs index b5ff5225f..d91c8eb7c 100644 --- a/tests/ImageProcessor.Tests/Processors/Samplers/SamplerTests.cs +++ b/tests/ImageProcessor.Tests/Processors/Samplers/SamplerTests.cs @@ -59,9 +59,9 @@ namespace ImageProcessor.Tests [Fact] public void ImageShouldEntropyCrop() { - if (!Directory.Exists("TestOutput/EntropyCropped")) + if (!Directory.Exists("TestOutput/EntropyCrop")) { - Directory.CreateDirectory("TestOutput/EntropyCropped"); + Directory.CreateDirectory("TestOutput/EntropyCrop"); } foreach (string file in Files) @@ -69,8 +69,8 @@ namespace ImageProcessor.Tests using (FileStream stream = File.OpenRead(file)) { Image image = new Image(stream); - string filename = Path.GetFileNameWithoutExtension(file) + "-EntropyCropped" + Path.GetExtension(file); - using (FileStream output = File.OpenWrite($"TestOutput/EntropyCropped/{filename}")) + string filename = Path.GetFileNameWithoutExtension(file) + "-EntropyCrop" + Path.GetExtension(file); + using (FileStream output = File.OpenWrite($"TestOutput/EntropyCrop/{filename}")) { image.EntropyCrop().Save(output); }