Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get/set individual pixels in image #16

Open
eigenhombre opened this issue Feb 7, 2015 · 4 comments
Open

Get/set individual pixels in image #16

eigenhombre opened this issue Feb 7, 2015 · 4 comments

Comments

@eigenhombre
Copy link
Contributor

Hi Mike, I'm playing with imagez for a small project.

Right away I wanted to be able to get or set individual pixels in an image. I first went down the hard path of pulling out pixels from the image into a Java array, aseting them, and putting them back using set-pixels. Then I discovered (.setRGB img x y color) which works quite well, though it requires digging into the details of BufferedImage. Would you be open to a PR that wrapped .getRGB and .setRGB into the API you're providing with this library?

@mikera
Copy link
Owner

mikera commented Feb 7, 2015

Yes I think that would be fine. Though it might be worth doing some benchmarking - individual pixel setting needs to be pretty fast in order to be useful in many cases so we don't want to encourage people to use an approach that adds unnecessary overheads.

@mikera
Copy link
Owner

mikera commented Feb 8, 2015

Probably an API function is OK as long as it gets inlined

@eigenhombre
Copy link
Contributor Author

Great! Regarding benchmarking: I am using it for this project (see screenshot) and the lines appear instantly on the image; so it's certainly fast enough for my purposes. I'm sure it won't be as fast as Java arrays, but you still have to set-pixels if you do it that way anyways (don't you?), so I'm not sure why that would matter.

I'll try to put something together tomorrow when I have a minute.

@mikera
Copy link
Owner

mikera commented Feb 8, 2015

Your project looks cool!

The array based stuff tends to have a slight advantage if you are doing something very customised and need to get / set a large number of times on the same data (implementing blurs, cellular automata, real-time animation, stuff like that...). You probably won't notice the difference if you are just setting some of the the pixels once :-)

so yes, I agree a nice interface to get / set pixels would be good for general purpose use.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants