Giter Site home page Giter Site logo

Comments (7)

Dhertz avatar Dhertz commented on June 1, 2024 1

@Gadgetoid this is what I ended up using:

    def load_image(path):
        i = Image.open(path)
        if display.colour == 'multi':
            data = np.array(i)
            black = data == display.BLACK
            white = data == display.WHITE
            green = data == display.GREEN
            data[black], data[white], data[green] = display.WHITE, display.BLACK, display.YELLOW
            i = Image.fromarray(data)
        return i   

from inky.

Gadgetoid avatar Gadgetoid commented on June 1, 2024

These are the real-world numbers that represent white/black on this particular e-ink display. Prior displays had a weirder, separate bit-packed buffer for white/black white/yellow (or red) so the mapping of number to colour was comparatively arbitary. Here I've opted to stay close to the metal, so to speak, and use the 4-bit values that actually get sent to the display.

The underlying buffer is just a numpy array, though, so you could replace colour values out at runtime if you needed.

from inky.

bablokb avatar bablokb commented on June 1, 2024

I will add a mapping dict to my code (e.g.

{ "black": display.BLACK, ... }

that will solve the issue but will change the format of the json causing some incompatibilities, but users will have to live with it (I don't think there are many users yet, ins a fairly new project).

from inky.

Dhertz avatar Dhertz commented on June 1, 2024

@Gadgetoid I am also having a similar problem converting code from the wHat - except I paste images from disk into a new PIL image that is black and white:

image = Image.new('P', (width, height))
icon = Image.open('icon.png')
image.paste(icon, (0,  0))

This code results in the correct image (as seen with an image editor) displayed on a wHat, but an inverted image on an Impression.

from inky.

bablokb avatar bablokb commented on June 1, 2024

You could try to setup your image as RGB for the impression. The impression-code will do the mapping to a palette image automatically hopefully preserving black&white. I use the colour-attribute of the display-object (returned by auto()) to distinguish the hardware (the impression will have the value multi).

from inky.

Gadgetoid avatar Gadgetoid commented on June 1, 2024

For the black/white swap you could run a pass after setting your image to swap Black and White in Inky's buffer, like so:

black = display.buf == display.BLACK
white = display.buf == display.WHITE
display.buf[black] = display.WHITE
display.buf[white] = display.BLACK

If this works, I'll add a display.swap method for Impressions, which you can pass any two colours into, ie:

display.swap(display.BLACK, display.WHITE)

from inky.

llego avatar llego commented on June 1, 2024

It seems to me that this is still broken. A PNG that I try to paste in has inverted black and white. The text in the example below, however, has the correct color...

img = Image.new("P", (inky_display.WIDTH, inky_display.HEIGHT))
draw = ImageDraw.Draw(img)

for y in range(inky_display.height):
	for x in range(inky_display.width):
		img.putpixel((x, y), inky_display.WHITE)

font = ImageFont.truetype(FredokaOne, 48)

message = u"{}°".format(temperature) 
w, h = font.getsize(message)
x = int((inky_display.WIDTH / 2) - (w / 2))
y = int((inky_display.HEIGHT / 2) - (h / 2))
draw.text((x, y), message, inky_display.BLACK, font)

img.paste(icon, (x, y + 20))

inky_display.set_image(img)
inky_display.show()

from inky.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.