Skip to content

Commit

Permalink
larger image scale
Browse files Browse the repository at this point in the history
  • Loading branch information
treethought committed Sep 10, 2021
1 parent 4094088 commit c4a1d15
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions ui/content.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ func (c *Content) SetItem(path string, entry *api.MfsLsEntry) {
}

switch contentType {
case "image/png":
case "image/png", "image/jpeg":
c.SetDynamicColors(true)
_, _, w, h := c.GetInnerRect()
_, _, w, h := c.GetRect()
r := bytes.NewReader(data)
img := translateImage(r, w, h)
c.SetText(img)
Expand All @@ -76,7 +76,6 @@ func (c *Content) SetItem(path string, entry *api.MfsLsEntry) {
}

c.ScrollToBeginning()
// })
}

func translateImage(reader io.Reader, x, y int) string {
Expand All @@ -90,8 +89,7 @@ func translateImage(reader io.Reader, x, y int) string {
}

func buildImage(reader io.Reader, x, y int) (*ansimage.ANSImage, error) {
pix, err := ansimage.NewScaledFromReader(reader, y, x, color.Transparent, ansimage.ScaleModeFill, ansimage.NoDithering)
// pix, err := ansimage.NewScaledFromURL(url, y, x, color.Transparent, ansimage.ScaleModeResize, ansimage.NoDithering)
pix, err := ansimage.NewScaledFromReader(reader, y, x, color.Transparent, ansimage.ScaleModeFit, ansimage.NoDithering)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit c4a1d15

Please sign in to comment.