go fmt
This commit is contained in:
@@ -1,3 +1 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
//go:build upsampling
|
//go:build upsampling
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@@ -5,19 +5,18 @@ import (
|
|||||||
"image"
|
"image"
|
||||||
|
|
||||||
"git.nkpl.cc/twocookedfaggots/imageutils/pkg/downscale"
|
"git.nkpl.cc/twocookedfaggots/imageutils/pkg/downscale"
|
||||||
"git.nkpl.cc/twocookedfaggots/imageutils/downscale"
|
|
||||||
"git.nkpl.cc/twocookedfaggots/imageutils/util"
|
"git.nkpl.cc/twocookedfaggots/imageutils/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
var x = flag.Int("x", 256, "dx value of new bounds")
|
var x = flag.Int("x", 1024, "dx value of new bounds")
|
||||||
var y = flag.Int("y", 256, "dy value of new bounds")
|
var y = flag.Int("y", 1024, "dy value of new bounds")
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
if err := util.ProcessStdio(func(img image.Image) image.Image {
|
if err := util.ProcessStdio(func(img image.Image) image.Image {
|
||||||
return downscale.GridDownscale{
|
return downscale.GridDownscale{
|
||||||
Image: img,
|
Image: img,
|
||||||
Rectangle: image.Rect(0,0,x,y),
|
NewBounds: image.Rect(0, 0, *x, *y),
|
||||||
}
|
}
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
|
|||||||
@@ -10,8 +10,6 @@ var (
|
|||||||
func main() {
|
func main() {
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
f, err := truetype.Parse(gomono.TTF)
|
f, err := truetype.Parse(gomono.TTF)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
|
|||||||
+1
-1
@@ -1,8 +1,8 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
|
||||||
"log"
|
"log"
|
||||||
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
type imageTransform struct {
|
type imageTransform struct {
|
||||||
|
|||||||
+5
-5
@@ -5,13 +5,13 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"image"
|
|
||||||
"image/color"
|
|
||||||
"image/png"
|
|
||||||
"image/jpeg"
|
|
||||||
"os"
|
|
||||||
"git.nkpl.cc/twocookedfaggots/imageutils"
|
"git.nkpl.cc/twocookedfaggots/imageutils"
|
||||||
"git.nkpl.cc/twocookedfaggots/imageutils/http/blank"
|
"git.nkpl.cc/twocookedfaggots/imageutils/http/blank"
|
||||||
|
"image"
|
||||||
|
"image/color"
|
||||||
|
"image/jpeg"
|
||||||
|
"image/png"
|
||||||
|
"os"
|
||||||
)
|
)
|
||||||
|
|
||||||
func BlankFillWhite(img image.Image) image.Image {
|
func BlankFillWhite(img image.Image) image.Image {
|
||||||
|
|||||||
Binary file not shown.
+11
-9
@@ -18,7 +18,7 @@ func (sub sub) At(x, y int) color.Color {
|
|||||||
|
|
||||||
type GridDownscale struct {
|
type GridDownscale struct {
|
||||||
image.Image
|
image.Image
|
||||||
newBounds image.Rectangle
|
NewBounds image.Rectangle
|
||||||
}
|
}
|
||||||
|
|
||||||
func blend(c1, c2 color.Color) color.RGBA {
|
func blend(c1, c2 color.Color) color.RGBA {
|
||||||
@@ -39,24 +39,25 @@ func blend(c1, c2 color.Color) color.RGBA {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func avgColor(img image.Image) (c color.Color) {
|
func avgColor(img image.Image) (c color.Color) {
|
||||||
dx, dy := img.Bounds().Dx(), img.Bounds().Dy()
|
b := img.Bounds()
|
||||||
for y := 0; y < dy; y++ {
|
c = img.At(b.Min.X, b.Min.Y)
|
||||||
for x := 0; x < dx; x++ {
|
for y := b.Min.Y; y < b.Max.Y; y++ {
|
||||||
|
for x := b.Min.X + 1; x < b.Max.X; x++ {
|
||||||
c = blend(c, img.At(x, y))
|
c = blend(c, img.At(x, y))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (grid grid) ColorModel() color.Model { return grid.Image.ColorModel }
|
func (grid GridDownscale) ColorModel() color.Model { return grid.Image.ColorModel() }
|
||||||
func (grid grid) Bounds() image.Rectangle { return grid.NewBounds }
|
func (grid GridDownscale) Bounds() image.Rectangle { return grid.NewBounds }
|
||||||
func (grid grid) At(x, y int) color.Color {
|
func (grid GridDownscale) At(x, y int) color.Color {
|
||||||
b := grid.Image.Bounds()
|
b := grid.Image.Bounds()
|
||||||
dx, dy := b.Dx(), b.Dy()
|
dx, dy := b.Dx(), b.Dy()
|
||||||
cellBounds := image.Rect(
|
cellBounds := image.Rect(
|
||||||
0, 0,
|
0, 0,
|
||||||
dx/grid.newBounds.Dx(),
|
dx/grid.NewBounds.Dx(),
|
||||||
dy/grid.newBounds.Dy(),
|
dy/grid.NewBounds.Dy(),
|
||||||
)
|
)
|
||||||
|
|
||||||
r := grid.Image.Bounds().Intersect(
|
r := grid.Image.Bounds().Intersect(
|
||||||
@@ -68,6 +69,7 @@ func (grid grid) At(x, y int) color.Color {
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
println(r.Min.X, r.Min.Y)
|
||||||
|
|
||||||
return avgColor(sub{grid.Image, r})
|
return avgColor(sub{grid.Image, r})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,7 +33,6 @@ func BenchmarkScale(b *testing.B) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
type SinglePixel struct{}
|
type SinglePixel struct{}
|
||||||
|
|
||||||
func (s SinglePixel) At(x, y int) color.Color {
|
func (s SinglePixel) At(x, y int) color.Color {
|
||||||
|
|||||||
Reference in New Issue
Block a user