views:

122

answers:

1

Hello,

I am working on a little side project (program for Android platform)and I don't exactly have a problem, but I don't really know where to start. The project I am working on has to do with getting the info and manipulating a pixel's RGB values inside an image. I know this is a very basic program (not going to disclose all the information about the project), but I am a beginning android programmer.

I've already developed my algorithm, now I just need to be pushed/"knudged" in the right direction. Could anyone please help me? Any tutorials on this kind of thing or related topics?

Thanks in advance!

A: 

What kind of object do you have? A Bitmap? If so, how about Bitmap.getPixel(int x, int y)?

EboMike
OP here,what if it isn't a bitmap? It will be a user inputted file, so it could really be any format, but the most common ones I will be working with are jpg/bmp/png.
mike
Well, what is it? If it's a jpg/bmp/png, then you'll turn it into a bitmap when you load it. You'll need to provide SOME hints on what your code is going to be like.
EboMike
Its just basically taking the RGB values of each individual pixel in an image and translating it to another value. Thats all. Are there any commands/libraries I could import for different file extensions?This is not an app to sell on an app store, this was just a project a friend and I are working on for fun.
mike
Android's `Bitmap` class is not specific to the .bmp file format, it simply represents bitmapped images in memory. The `BitmapFactory` class will happily parse a number of popular file formats into `Bitmap` objects for you. (.jpg, .png, etc.)
adamp
So what you are saying is that Android's Bitmap class essentially "converts" popular file extensions, like .jpg, into a .bmp and then you are able to use Bitmap.getPixel(int x, int y)? Is there any quality loss?
mike
I think you're still mixing up "Bitmap" and "BMP". "Bitmap" is a generic Android class that contains an image. It's a 2D image based on pixels (versus something curve-and-line based, like SVG), hence Bitmap. How you create this Bitmap is a different issue. You could do it from scratch, or you could load a BMP, JPG, PNG file - as Adam pointed out, the BitmapFactory class has some static members that let you do this with one line of code. And there's no quality loss in decoding. (Obviously, if it's a JPG, there had been quality loss when it was created in the first place.)
EboMike
So basically what you're saying is, Bitmap is a class and all I have to do is import that class and can use the .getPixel(int, int) command to basically get a certain pixel at point (x,y) on any popular file format?! Wow, I thought it would be much harder than that. Thanks a lot!
mike
It is as easy as that. Android is awesome, after all :) (Btw, not to be pushy, but if it works out for you, please consider marking the answer as "best answer" to give both of us a better score)
EboMike
Ok I checked the green arrow. Thanks for all the help, Ebomike and adamp.
mike