コード例 #1
0
ファイル: levels.go プロジェクト: hawx/img
func runLevelsOnChannel(cmd *hadfield.Command, args []string, img image.Image,
	ch channel.Channel) image.Image {

	if levelsAuto {
		img = levels.Auto(img, ch)

	} else if levelsAutoBlack {
		img = levels.AutoBlack(img, ch)

	} else if levelsAutoWhite {
		img = levels.AutoWhite(img, ch)

	} else if utils.FlagVisited("black", cmd.Flag) {
		img = levels.SetBlack(img, ch, levelsBlack)

	} else if utils.FlagVisited("white", cmd.Flag) {
		img = levels.SetWhite(img, ch, levelsWhite)

	} else if utils.FlagVisited("curve", cmd.Flag) {
		img = levels.SetCurve(img, ch, levels.ParseCurveString(levelsCurve))
	}

	return img
}
コード例 #2
0
ファイル: channel.go プロジェクト: hawx/img
func runChannel(cmd *hadfield.Command, args []string) {
	i, data := utils.ReadStdin()
	var adj utils.Adjuster

	if utils.FlagVisited("by", cmd.Flag) {
		adj = utils.Adder(channelBy)
	} else {
		adj = utils.Multiplier(channelRatio)
	}

	if !(channelRed || channelGreen || channelBlue || channelHue ||
		channelSaturation || channelLightness || channelBrightness || channelAlpha) {
		channelRed = true
		channelGreen = true
		channelBlue = true
	}

	if channelRed {
		i = channel.Adjust(i, adj, channel.Red)
	}
	if channelGreen {
		i = channel.Adjust(i, adj, channel.Green)
	}
	if channelBlue {
		i = channel.Adjust(i, adj, channel.Blue)
	}

	if channelHue {
		i = channel.Adjust(i, adj, channel.Hue)
	}
	if channelSaturation {
		i = channel.Adjust(i, adj, channel.Saturation)
	}
	if channelLightness {
		i = channel.Adjust(i, adj, channel.Lightness)
	}
	if channelBrightness {
		i = channel.Adjust(i, adj, channel.Brightness)
	}

	if channelAlpha {
		i = channel.Adjust(i, adj, channel.Alpha)
	}

	utils.WriteStdout(i, data)
}