I can't seem to find a good answer for this anywhere.
Is it possible to extract the a single pixel rgb directly from an android screen? (Not by taking a screen dump)
I need direct access to what's on the screen.
Any thoughts?
Thanks.
I don't know exactly but I can give you an approach.
if the view's drawingCache enabled you can get bitmap from getDrawingCache and you can get pixel data from that.
If you are using custom views and canvases, you definitely can:
have a look:
http://developer.android.com/reference/android/graphics/Bitmap.html#getPixel(int,int)
Related
I need the code to add invisible watermark to another image in Android
As the comments mentioned, Stackoverflow isn't a free coding service. I will provide you with a high level design advice from which you can implement your own code.
Invisible watermark could just be metadata. The point is to make your particular photo unique and identifiable, right? I would recommend you looking into image metadata manipulation for a simple solution.
That being said, if you are looking for some high tech stealthy watermarking, then you might be looking for pixel manipulation. You can change a few of the pixel colors so if it's compared with the original image with the naked eye, it looks identical but if compared with their base64 encoding you can see a difference. Simply create your own pattern as some sort of signature to attach to images to identify them.
Both method allows you to determine if an image is yours due to the "watermark" you leave on it.
I implemented QueueLinearFloodFill Algorithm it works fast for me, but the images I am using are .PNG type, all good quality images are also returning in the issue that white part is left uncolored at border. So Can I use SVG/Vector type. and if yes how.
Thanks in advance
I'm trying to create a cross-platform app.
So I have an image 1000x200 and I want to position it as image on background.
I try to calculate a real image size, to get it perfect on each screen. Because titanium resizes images and scales them in some magic way...
menuBottomImageView.toImage().width works fine on iOS and I get 1000px, but on android I get not the real size, only the displayed size and that's not what I need.
Is there a way to get the real dimensions of a file for both systems?
for Android there is no better method, if you use getWidth() method, it will give createImageView()'s width, mentioned in the object. best one is your method menuBottomImageView.toImage().width .
I don't have Android set up to test it, but on iOS I've discovered you can use:
var imgBlob = menuBottomImageView.toBlob(),
imgWidth = imgBlob.width,
imgHeight = imgBlob.height;
Using toBlob() is also much faster than using toImage(). According to the docs this is supported on Android, but then the docs say lots of things that don't always work out.
If the controller you are asking for toImage() is added and loaded on window then only it will give you proper size.
i want my gallery application to be modified , like coverflow. but not exactly like coverflow. the images in the gallery view should be viewed in such a way that it should look like reverse letter "U" . i want to change the angle image in such a way that it has to go slightly go above the previous image so that i can achieve the reverse "U" for gallery view.
There are already widgets out there that you can consider using. I found one http://www.inter-fuser.com/2010/02/android-coverflow-widget-v2.html that looks very good, but it might not be exactly what you are looking for.
Here is another one based on the interfuser widget. http://code.google.com/p/android-coverflow/.
They claim to have improved the performance of it.
Whether you can use them as is or not, you can probably use the source as inspiration.
You can use preRotate or postRotate methods in android.graphics.Matrix. Check them once.
Android has a nice way of defining stretchable images called a nine-patch. See these docs for a description of the concept. The idea is to surround a png image with a 1-pixel border where you can define the stretchable areas and the padding dimensions of the image. This is absolutely brilliant and I'd like to use the idea in my iPhone app. Before writing my own nine-patch to UIImage loader I thought I'd see if one already exists. Google doesn't return any results so I don't have much hope, but it doesn't hurt to ask, right? :-)
EDIT: Folks, I appreciate the answers but I know about stretchableImageWithLeftCapWidth.... I'm looking for code that takes a path #"foo.9.png" and returns a stretchable UIImage. This code will undoubtedly use stretchableImageWithLeftCapWidth... internally. I'm sure I could write the code myself using that method. But I'm asking if somebody else has already done it.
I received an e-mail from Tortuga22 software who informed me that they have created such a library and released it under the Apache license:
Announcement: http://blog.tortuga22.com/2010/05/31/announcing-tortuga-22-ninepatch/
Source code: http://github.com/tortuga22/Tortuga22-NinePatch
Example usage:
// loads-and-caches ninepatch and rendered image of requested size
UIImage buttonImg = [TUNinePatchCache imageOfSize:buttonSize
forNinePatchNamed:#"buttonNormalBackground"];
[self.buttonNeedingBackground setImage:buttonImg
forControlState:UIControlStateNormal];
Also look at UIView's contentStretch property. It is more robust and well-behaved than stretchableImageWithLeftCapWidth. Basically, it works by just defining the stretchable rectangle within your image and automatically creating a scaled nine-patch. This internal rectangle can be anything - it doesn't even have to be in the center of the image. Plus unlike stretchableImage this method will properly shrink graphics and behave as expected for graphics with lighting or gloss. I can't think of any real-world application where you would want more than this.
Yes UIImage does support something like it. See
- (UIImage *)stretchableImageWithLeftCapWidth:(NSInteger)leftCapWidth topCapHeight:(NSInteger)topCapHeight and the documentation for leftCapWidth and topCapHeight
basically the image is not stretched in the area leftCapWidth pixels from the left and right edge and topCapHeight pixels from the top and the bottom. When the image is scaled the area inside of these limits is subject to stretching.
All UIImage images support this natively. By default the entire images is stretchable, but you can set caps with the leftCapWidth and topCapHeight properties or you can generate one from an existing UIImage with the - (UIImage *)stretchableImageWithLeftCapWidth:(NSInteger)leftCapWidth topCapHeight:(NSInteger)topCapHeight method.
Do note that in apple's implementation, when you set one or both of these values, the stretchable area is forced to be a single pixel high/wide.