Compare commits
2 Commits
729a636b9b
...
329b115e69
| Author | SHA1 | Date | |
|---|---|---|---|
| 329b115e69 | |||
| 445a6aab94 |
@@ -2,3 +2,6 @@ child_porn
|
||||
imageutils.test
|
||||
cpu.out
|
||||
profile.out
|
||||
*.png
|
||||
*.jpg
|
||||
*.jpeg
|
||||
@@ -1,3 +1 @@
|
||||
package main
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
//go:build upsampling
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
|
||||
@@ -5,19 +5,18 @@ import (
|
||||
"image"
|
||||
|
||||
"git.nkpl.cc/twocookedfaggots/imageutils/pkg/downscale"
|
||||
"git.nkpl.cc/twocookedfaggots/imageutils/downscale"
|
||||
"git.nkpl.cc/twocookedfaggots/imageutils/util"
|
||||
)
|
||||
|
||||
var x = flag.Int("x", 256, "dx value of new bounds")
|
||||
var y = flag.Int("y", 256, "dy value of new bounds")
|
||||
var x = flag.Int("x", 1024, "dx value of new bounds")
|
||||
var y = flag.Int("y", 1024, "dy value of new bounds")
|
||||
|
||||
func main() {
|
||||
flag.Parse()
|
||||
if err := util.ProcessStdio(func(img image.Image) image.Image {
|
||||
return downscale.GridDownscale{
|
||||
Image: img,
|
||||
Rectangle: image.Rect(0,0,x,y),
|
||||
NewBounds: image.Rect(0, 0, *x, *y),
|
||||
}
|
||||
}); err != nil {
|
||||
panic(err)
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 9.5 MiB |
@@ -10,8 +10,6 @@ var (
|
||||
func main() {
|
||||
flag.Parse()
|
||||
|
||||
|
||||
|
||||
f, err := truetype.Parse(gomono.TTF)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
||||
+1
-1
@@ -1,8 +1,8 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"log"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type imageTransform struct {
|
||||
|
||||
+5
-5
@@ -5,13 +5,13 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"image"
|
||||
"image/color"
|
||||
"image/png"
|
||||
"image/jpeg"
|
||||
"os"
|
||||
"git.nkpl.cc/twocookedfaggots/imageutils"
|
||||
"git.nkpl.cc/twocookedfaggots/imageutils/http/blank"
|
||||
"image"
|
||||
"image/color"
|
||||
"image/jpeg"
|
||||
"image/png"
|
||||
"os"
|
||||
)
|
||||
|
||||
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 {
|
||||
image.Image
|
||||
newBounds image.Rectangle
|
||||
NewBounds image.Rectangle
|
||||
}
|
||||
|
||||
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) {
|
||||
dx, dy := img.Bounds().Dx(), img.Bounds().Dy()
|
||||
for y := 0; y < dy; y++ {
|
||||
for x := 0; x < dx; x++ {
|
||||
b := img.Bounds()
|
||||
c = img.At(b.Min.X, b.Min.Y)
|
||||
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))
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (grid grid) ColorModel() color.Model { return grid.Image.ColorModel }
|
||||
func (grid grid) Bounds() image.Rectangle { return grid.NewBounds }
|
||||
func (grid grid) At(x, y int) color.Color {
|
||||
func (grid GridDownscale) ColorModel() color.Model { return grid.Image.ColorModel() }
|
||||
func (grid GridDownscale) Bounds() image.Rectangle { return grid.NewBounds }
|
||||
func (grid GridDownscale) At(x, y int) color.Color {
|
||||
b := grid.Image.Bounds()
|
||||
dx, dy := b.Dx(), b.Dy()
|
||||
cellBounds := image.Rect(
|
||||
0, 0,
|
||||
dx/grid.newBounds.Dx(),
|
||||
dy/grid.newBounds.Dy(),
|
||||
dx/grid.NewBounds.Dx(),
|
||||
dy/grid.NewBounds.Dy(),
|
||||
)
|
||||
|
||||
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})
|
||||
}
|
||||
|
||||
@@ -33,7 +33,6 @@ func BenchmarkScale(b *testing.B) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
type SinglePixel struct{}
|
||||
|
||||
func (s SinglePixel) At(x, y int) color.Color {
|
||||
|
||||
Reference in New Issue
Block a user