Пример #1
0
// Generates a B/W image file
func generateImage(imgout string, binaryArray []byte) error {
	// Encodes the binary in a colorful or B/W image
	encoder, binImage := image.EncodeBW(binaryArray)

	// Write image to file
	malPict, err := os.Create(imgout + ".png")
	if err != nil {
		return err
	}
	encoder.Encode(malPict, binImage)

	return nil
}
Пример #2
0
// Generates a B/W image file
func generateImage(imgout, filePath string) error {
	// Read file to byte array
	binaryArray, err := ioutil.ReadFile(filePath)
	if err != nil {
		return err
	}

	// Encodes the binary in a colorful or B/W image
	encoder, binImage := image.EncodeBW(binaryArray)

	// Write image to file
	malPict, err := os.Create(imgout)
	if err != nil {
		return err
	}
	encoder.Encode(malPict, binImage)

	return nil
}