Last active
August 29, 2015 14:20
-
-
Save esdrasbeleza/05c6806b7f780b66db16 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func (c LightestOperation) Result(images []containers.ImageContainer) (image.Image, error) { | |
if len(images) == 0 { | |
return nil, nil | |
} else if len(images) == 1 { | |
return images[0].GetImage(), nil | |
} | |
firstImage := images[0].GetImage() | |
bounds := firstImage.Bounds() | |
lightest := image.NewRGBA(image.Rect(0, 0, bounds.Dx(), bounds.Dy())) | |
draw.Draw(lightest, bounds, firstImage, bounds.Min, draw.Src) | |
for _, currentImageContainer := range images[1:] { | |
currentImage := currentImageContainer.GetImage() | |
if currentImage.Bounds() != bounds { | |
return nil, errors.New("The images have different size!") | |
} | |
imageToCompare := image.NewRGBA(image.Rect(0, 0, bounds.Dx(), bounds.Dy())) | |
draw.Draw(imageToCompare, bounds, currentImage, bounds.Min, draw.Src) | |
c.getLightestImageBetweenTwo(lightest, imageToCompare) | |
} | |
return lightest, nil | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment