mirror of
https://github.com/ivanizag/izapple2.git
synced 2025-01-02 20:29:44 +00:00
Press F12 to save a screen capture
This commit is contained in:
parent
343df8a554
commit
fc9e4011f9
Binary file not shown.
@ -101,6 +101,8 @@ func (k *sdlKeyboard) putKey(keyEvent *sdl.KeyboardEvent) {
|
||||
k.a.SendCommand(apple2.CommandLoadState)
|
||||
case sdl.K_F9:
|
||||
k.a.SendCommand(apple2.CommandDumpDebugInfo)
|
||||
case sdl.K_F12:
|
||||
apple2.SaveSnapshot(k.a, "snapshot.png")
|
||||
}
|
||||
|
||||
// Missing values 91 to 95. Usually control for [\]^_
|
||||
|
23
screen.go
23
screen.go
@ -95,13 +95,15 @@ func mixSnapshots(top, bottom *image.RGBA) *image.RGBA {
|
||||
return out
|
||||
}
|
||||
|
||||
func saveSnapshot(a *Apple2) {
|
||||
// SaveSnapshot saves a snapshot of the screen to a png file
|
||||
func SaveSnapshot(a *Apple2, filename string) {
|
||||
img := Snapshot(a)
|
||||
if img == nil {
|
||||
return
|
||||
}
|
||||
img = squarishPixelsFilter(img)
|
||||
|
||||
f, err := os.Create("snapshot.png")
|
||||
f, err := os.Create(filename)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@ -112,6 +114,23 @@ func saveSnapshot(a *Apple2) {
|
||||
png.Encode(f, img)
|
||||
}
|
||||
|
||||
func squarishPixelsFilter(in *image.RGBA) *image.RGBA {
|
||||
b := in.Bounds()
|
||||
factor := 1200 / b.Dx()
|
||||
fmt.Println(factor)
|
||||
size := image.Rect(0, 0, factor*b.Dx(), b.Dy())
|
||||
out := image.NewRGBA(size)
|
||||
for x := b.Min.X; x < b.Max.X; x++ {
|
||||
for y := b.Min.Y; y < b.Max.Y; y++ {
|
||||
c := in.At(x, y)
|
||||
for i := 0; i < factor; i++ {
|
||||
out.Set(factor*x+i, y, c)
|
||||
}
|
||||
}
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func linesSeparatedFilter(in *image.RGBA) *image.RGBA {
|
||||
b := in.Bounds()
|
||||
size := image.Rect(0, 0, b.Dx(), 4*b.Dy())
|
||||
|
Loading…
Reference in New Issue
Block a user