Basic go based rendering
This commit is contained in:
parent
7f866b2b1f
commit
373ab95f14
@ -4,9 +4,29 @@ package icat
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"image"
|
||||
|
||||
"golang.org/x/image/draw"
|
||||
)
|
||||
|
||||
var _ = fmt.Print
|
||||
|
||||
func render_image_with_go(imgd *image_data, src *opened_input) {
|
||||
func render_image_with_go(imgd *image_data, src *opened_input) (err error) {
|
||||
switch imgd.format_uppercase {
|
||||
case "GIF":
|
||||
return fmt.Errorf("TODO: implement GIF decoding")
|
||||
default:
|
||||
img, _, err := image.Decode(src.file)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
b := img.Bounds()
|
||||
rgba := image.NewNRGBA(image.Rect(0, 0, b.Dx(), b.Dy()))
|
||||
draw.Draw(rgba, rgba.Bounds(), img, b.Min, draw.Src)
|
||||
imgd.format_uppercase = "RGBA"
|
||||
f := image_frame{width: b.Dx(), height: b.Dy()}
|
||||
f.in_memory_bytes = rgba.Pix
|
||||
imgd.frames = append(imgd.frames, &f)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -251,7 +251,7 @@ func process_arg(arg input_arg) {
|
||||
send_output(&imgd)
|
||||
return
|
||||
}
|
||||
err = render_image_with_go(imgd, &f)
|
||||
err = render_image_with_go(&imgd, &f)
|
||||
if err != nil {
|
||||
report_error(arg.value, "Could not render image to RGB", err)
|
||||
return
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user