Skip to content

Commit

Permalink
Fixing Bug for GetPixel Transparency.
Browse files Browse the repository at this point in the history
  • Loading branch information
JewishLewish committed Jan 11, 2023
1 parent 04b962d commit f22df47
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 25 deletions.
25 changes: 1 addition & 24 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,29 +58,6 @@ func main() {
fmt.Print("Website is being operated!\n")

draw.Draw(cimg, img.Bounds(), img, image.Point{}, draw.Over)
if set.Pmap {
fmt.Print("Applying mask... \n")
file2, err := os.Open("placeable.png")
if err != nil {
fmt.Print(err)
}

Pmapc, _, _ := image.Decode(file2)
file2.Close()

b := Pmapc.Bounds()
transparentImg := image.NewRGBA(b)
draw.Draw(transparentImg, b, Pmapc, image.Point{}, draw.Src)
for y := 0; y < b.Max.Y; y++ {
for x := 0; x < b.Max.X; x++ {
_, _, _, a := transparentImg.At(x, y).RGBA()
if a == 0xffff {
transparentImg.Set(x, y, color.Transparent)
}
}
}
draw.Draw(cimg, b, transparentImg, image.Point{}, draw.Over)
}

fmt.Print("Image has been created! \n")

Expand Down Expand Up @@ -153,7 +130,7 @@ func getpixel(w http.ResponseWriter, r *http.Request) {

re, g, b, a := cimg.At(locX, locY).RGBA()

if a != 255 {
if a == 0 {
info := info{T: false}
json.NewEncoder(w).Encode(info)
} else {
Expand Down
2 changes: 1 addition & 1 deletion settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
"address":"0.0.0.0",
"ratelimit":180,
"sitefiles": "static/index.html",
"useplacemap": true
"useplacemap": false
}

0 comments on commit f22df47

Please sign in to comment.