()
| 4 | import "github.com/gographics/imagick/imagick" |
| 5 | |
| 6 | func main() { |
| 7 | imagick.Initialize() |
| 8 | defer imagick.Terminate() |
| 9 | |
| 10 | mw := imagick.NewMagickWand() |
| 11 | |
| 12 | mw.ReadImage("logo:") |
| 13 | width := mw.GetImageWidth() |
| 14 | height := mw.GetImageHeight() |
| 15 | |
| 16 | mwl := imagick.NewMagickWand() |
| 17 | mwb := imagick.NewMagickWand() |
| 18 | |
| 19 | // Set the hsl and hsb images to the same size as the input image |
| 20 | mwl.SetSize(width, height) |
| 21 | mwb.SetSize(width, height) |
| 22 | // Even though we won't be reading these images they must be initialized |
| 23 | // to something |
| 24 | mwb.ReadImage("xc:none") |
| 25 | mwl.ReadImage("xc:none") |
| 26 | |
| 27 | // Create iterators for each image |
| 28 | imw := mw.NewPixelIterator() |
| 29 | imwl := mwl.NewPixelIterator() |
| 30 | imwb := mwb.NewPixelIterator() |
| 31 | |
| 32 | for y := 0; y < int(height); y++ { |
| 33 | // Get the next row from each image |
| 34 | pmw := imw.GetNextIteratorRow() |
| 35 | pmwl := imwl.GetNextIteratorRow() |
| 36 | pmwb := imwb.GetNextIteratorRow() |
| 37 | for x := 0; x < int(width); x++ { |
| 38 | // Get the RGB quanta from the source image |
| 39 | qr := pmw[x].GetRedQuantum() |
| 40 | qg := pmw[x].GetGreenQuantum() |
| 41 | qb := pmw[x].GetBlueQuantum() |
| 42 | |
| 43 | // Convert the source quanta to HSB |
| 44 | bh, bs, bb := imagick.ConvertRGBToHSB(qr, qg, qb) |
| 45 | bb *= 0.5 |
| 46 | qrb, qgb, qbb := imagick.ConvertHSBToRGB(bh, bs, bb) |
| 47 | // Set the pixel in the HSB output image |
| 48 | pmwb[x].SetRedQuantum(qrb) |
| 49 | pmwb[x].SetGreenQuantum(qgb) |
| 50 | pmwb[x].SetBlueQuantum(qbb) |
| 51 | |
| 52 | // Convert the source quanta to HSL |
| 53 | lh, ls, ll := imagick.ConvertRGBToHSL(qr, qg, qb) |
| 54 | ll *= 0.5 |
| 55 | qrl, qgl, qbl := imagick.ConvertHSLToRGB(lh, ls, ll) |
| 56 | // Set the pixel in the HSL output image |
| 57 | pmwl[x].SetRedQuantum(qrl) |
| 58 | pmwl[x].SetGreenQuantum(qgl) |
| 59 | pmwl[x].SetBlueQuantum(qbl) |
| 60 | } |
| 61 | // Sync writes the pixels back to the magick wands |
| 62 | imwl.SyncIterator() |
| 63 | imwl.SyncIterator() |
nothing calls this directly
no test coverage detected