Android :: Trying To Grayscale Bitmap?

Apr 20, 2009

I am trying to grayscale bitmap as follows, But it is crashing as soon as I run this method.

The problem is in last line. How can I assign "int" to "Color"? Or are there any better ways?

CODE:................

Android :: trying to grayscale bitmap?


Android :: Converting Bitmap To Grayscale

May 20, 2009

I would like to convert a Bitmap to a grayscale array of bytes (one byte per pixel). At the same time I want to just crop at section from the middle. Having looked though the various api's it is not clear to me what the best way would be.

1) What is ALPHA_8? is that grayscale? I have a feeling that the grayscale effect should be done via some "saturation" on the paint object, right?

2) once I have the Bitmap in grayscale and the right size, what is the best way to get that to a byte[] of pixels (one byte per pixel)?

View 2 Replies View Related

Android :: Convert A Bitmap To GrayScale In Droid?

Jul 30, 2010

I am new to this site, and I come with a question about Android.

Is there any way to convert a Bitmap to grayscale? I know how to draw a grayscale bitmap (using canvas operations: http://www.mail-archive.com/android-developers@googlegroups.com/msg38890.html) but I really need The actual bitmap in gray colors (or at least something that could be converted to a bitmap later on).
Do I have to implement it by hand (pixel by pixel operations)?

I've searched a lot, and still could not find. Anyone knows a easy/efficient way to do it?

View 2 Replies View Related

Android :: Turn A Color Bmp To Grayscale?

Jul 5, 2010

I've seen this code on the web...

My questions are:
1. Is 'bmp' supposed to be the color bitmap I want to affect?
2. How do I get the 0-255 value of the grayscale?

View 1 Replies View Related

Android : Crop Bitmap Without Reading Entire Bitmap / Cannot Read Image Into Memory

Jul 21, 2010

I have a very large image and I only want to display a section the size of the display (no scaling), and the section should just be the center of the image. Because the image is very large I cannot read the entire image into memory and then crop it. This is what I have so far but it will give OutOfMemory for large images. Also I don't think inSampleSize applies because I want to crop the image, not lower the resolution.

Uri data = getIntent().getData();
Input Stream is = getContentResolver().openInputStream(data);
Bitmap bitmap = BitmapFactory.decodeStream(is, null, null);

Any help would be great?

View 3 Replies View Related

Android :: Create Mutable Bitmap From Camera - Draw Another Bitmap On Top - And Save It

Apr 2, 2009

I am 1) taking a picture and 2) then draw another Bitmap on top of it 3) then I store it

I am doing it as follows and it works on the emulator.

On the device I get a OutOfMemoryError: bitmap size exceeds VM budget android.graphics.Bitmap.nativeCopy(Native Method) android.graphics.Bitmap.copy(Bitmap.java:199) in the line copy the Bitmap to get a mutable Bitmap.

CODE:...........

What I am asking:

a) Is there a better way to do what I am doing? 1) take a picture 2) draw another Bitmap on top of it 3) then I store it

b) What is the best way to create a mutable Bitmap from the picture I just took with the camera?

In my app, resolution is not an issue. If it works better for small photos that would be fine.

View 3 Replies View Related

Android :: Want To Convert Image Captured By Camera To Grayscale?

Jul 8, 2009

I have a camera application that captures a 640x480 image.I want to convert this image to grayscale.I know I have to use the setSaturatio (float sat) in the ColorMatrix method to zero but I don't know how I can set it to grayscale.

View 3 Replies View Related

Android :: Turn A Color Drawable Into A Grayscale One (to Indicate Disabled State)?

Nov 24, 2009

What would be the right way to turn a color Drawable into a grayscale one (to indicate disabled state)?

View 3 Replies View Related

Android :: Apply / Convert Image From Colored To Grayscale Algorithm To Droid?

Oct 28, 2010

I am trying to use one of these algorithms to convert a RGB image to grayscale :

The lightness method averages the most prominent and least prominent colors:
(max(R, G, B) + min(R, G, B)) / 2.

The average method simply averages the values: (R + G + B) / 3.

The formula for luminosity is 0.21 R + 0.71 G + 0.07 B.
But i get very weird results ! I know there are other ways to achieve this but is it possible to do this way ?

here is the code...

View 4 Replies View Related

Android :: Overlay Bitmap - Draw Over A Bitmap

Oct 8, 2009

I have two questions actually:

Is it better to draw an image on a bitmap or create a bitmap as resource and then draw it over a bitmap? Performance wise... which one is better?

If I want to draw something transparent over a bitmap, how would I go about doing it?

If I want to overlay one transparent bitmap over another, how would I do it?

View 1 Replies View Related

Android :: Draw A Bitmap Rotated Onto Another Bitmap

Mar 22, 2009

My goal is the draw a bitmap onto another bitmap but rotated 90 degress. whats the most efficient way to do that. My current method is as follows which is horribly bad because it creates a new bitmap every time.

CODE:.....................

View 4 Replies View Related

Accessing Grayscale Data From A Photo?

Oct 7, 2012

I am wondering how do I go about writing code (or be directed to any existing relevant code), that allows me to average the grayscale values above a threshold (Otsu threshold) from a JPEG photo taken from an android device camera.

View 2 Replies View Related

How To Get Grayscale Pixel Data From Image Or Preview

May 8, 2013

What I am needing is a method to get grayscale pixel data from an image or preview. I am not interested in saving the picture as a jpeg etc, just need the grayscale data.

I am aiming at API 10 (as this is the device available for testing).

On top of this, I am not having any luck getting the camera to work on the Eclipse emulator.

View 3 Replies View Related

Android :: Draw Shape Or Bitmap Into Another Bitmap - Java - Android

Jun 22, 2010

I want to draw a shape(many circles particularly) into a Specific Bitmap. I have never used canvas / 2D graphs etc. As i see it i create a Drawable put the bitmap in it then "canvas-it" to the shapes i want etc.

View 1 Replies View Related

Android :: Draw On Bitmap

Nov 11, 2010

I'm trying to figure out how to draw on a bitmap in android, and keep a copy of these changed bitmaps for an undo function.

Bitmap b = ...
Paint p = new Paint();
canvas.drawBitmap(b, new Matrix(), null);
canvas.drawCircle(0,0,20,20);
//does Bitmap b have the circle drawn on it next time?

Or how do I get the bitmap after its been drawn on with the canvas(I want to preserve a stack of bitmaps with the changes applied by canvas drawing)? Maybe I'm going about this entirely wrong.

View 1 Replies View Related

Android :: Getting Bitmap From TextView

Jun 13, 2010

I want to get the bitmap that is drawn when a textview is displayed but without displaying the textview in the activity. something like this:

TextView t = new TextView(this);
t.forceToDrawItself();
Bitmap b=t.getViewBitmap();

how is this possible?

View 2 Replies View Related

Android : How To Put Bitmap On Top Of A Button?

Apr 21, 2009

Does anybody knows how can I put a Bitmap on top of a button, but without taking the whole surface?

View 2 Replies View Related

Android : Best Way To Resize Bitmap

Sep 10, 2009

I want to resize a bitmap and write to a file. what's the best way to do that?

View 2 Replies View Related

Android : How To Merge Two Bitmap Into One

Mar 15, 2010

I have two different bitmap. Can I merge these two bitmap into one?

View 7 Replies View Related

Android :: Passing Bitmap To Another Activity

Jun 7, 2010

I have a Bitmap image and i want to forward the bitmap to another activity. I have two activities Activity A and Activity B. This is how I started the Activity B
startActivityForResult(new Intent(Activity A.this, Activity B.class), 120);
in activity B
private void forwardImage(Bitmap bit) {
Intent i = new Intent(MMS.this, Compose.class);
i.putExtra("MMS", bit);
setResult(RESULT_OK, i);
finish(); }

This is not forwarding to Activity A but if I put a String to the intent it'll forward. This is how I listen to result in Activity A

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// TODO Auto-generated method stub
// super.onActivityResult(requestCode, resultCode, data);
switch (resultCode)
case RESULT_OK: Intent intent = getIntent();
Bitmap bitmap = (Bitmap) intent.getParcelableExtra("MMS");
mmsImage.setImageBitmap(bitmap);
default: break;
} }

How can I pass a bitmap.

View 3 Replies View Related

Android :: Write Comment On Bitmap

Nov 22, 2010

I have a bitmap displayed on ImageView now i want to give a facility to write comment typed by the user on that bitmap.i tried using Canvas canvas = new Canvas(srcBitmap); canvas.drawText("Hello", 100,100,null);but this is giving me following error java.lang.IllegalStateException: Immutable bitmap passed to Canvas constructor later on i want to save this whole image a bitmap.

View 1 Replies View Related

Android :: Replace Any Colour In Bitmap Possible?

Oct 28, 2010

Is there an easy way to replace a colour in a bitmap?

View 2 Replies View Related

Android :: Converting Bitmap To ASCII

Sep 17, 2010

I have a picture taken using the phone's camera and in bitmap format. I want to send it over HTTP usinf Http post in ASCII.Any idea how to do it?

View 4 Replies View Related

Android :: Why Bitmap Is Placed On An An Imageview Incorrectly?

Nov 24, 2010

this problem has been bothering me for days and I cannot figure out why on earth it is happening. I have a method that detects for a face, if a face is detected, the method will draw a rectangle on a canvas along the face.That part works fine.The problem is, when it displays to the image_view in my xml file, it will display on the far left middle of the image view, in a box, rather than in the center with the width as fill_parent.I thought of a possible workaround : to set the bitmap as a bitmapdrawable, but canvas only draws to bitmaps, so I can get the bitmapdrawable in the middle, but with no red box around it.I commented out my testing of bitmap drawable, and left it as what I have now...it only displays to my xml in the far left of the image_view.

View 1 Replies View Related

Android :: RuntimeException On Widget That Has A Bitmap

Aug 23, 2010

my app has widgets that have an ImageView and a TextView. On the onUpdate() method of the WidgetProvider, I put a Bitmap inside the ImageView this way:

CODE:..................

setColor() method is this:

CODE:..........

The problem is that sometimes the widget throws a RuntimeException because somebody has recycled the Bitmap, and I don't know what to do.

View 2 Replies View Related

Android :: Batch Getting Many Bitmap Resources?

Jan 24, 2010

I have a long series of graphics -- icon1_0.png, icon1_1.png, icon1_2.png..., icon12_0.png, icon12_1.png, icon12_2.png -- and I'd like to package them with my android application. Ideally I think I should be able to load them as resources but the resource id's are set up as java identifiers. Of course, java identifiers can't be assembled at runtime. I have to ask for R.drawable.icon12_00 so I cannot set up a loop

for(int icon=0;icon<12;icon++)
for(int frame=0;frame<3;frame++)
//syntax error obviously
BitmapFactory.decodeResource(getResources(), R.drawable."icon" + icon + "_" + frame + ".png");

So is there any way to get resources by their names? Better yet, is there a canonical way outside the resource system to pack data files into an android application package so that I can get at them? I'm thinking about reflection but that doesn't seem like the right solution to me.

View 3 Replies View Related

Android :: Temp Storage For Bitmap

Oct 13, 2009

My program creates a bitmap and successfully stores it on external storage (Images.Media.EXTERNAL_CONTENT_URI).

The next option to implement is to share the image. I'm thinking about different way of doing it: 1. Save it as captured image (as before) and startActivity with Intent.ACTION_SEND intent with the saved image uri. 2. Save it in application's home directory (getFileStreamPath()), startActivityForResult as in 1. and I hope that I'll recieve a result when the message is sent. 3. Save it in some kind of temp/cache folder and don't bother about deleting it or delete it as in 2.

Personally I prefer the second option.

My questions are: Will it work with startActivityForResult() as in 2. ? Do I have access to temp/cache folder as in 3. ? If I do, Should I delete the file afterwards ? May be some flag for Intent.ACTION_SEND to delete the file afterwards ?

View 6 Replies View Related

Android :: Draw Text On A Bitmap

Jun 14, 2009

Can i draw text on a bitmap? I cannot find any API support this.

View 4 Replies View Related

Android :: Draw GLSurfaceView To A Bitmap

Nov 4, 2009

I have an application that uses GLSurfaceView to draw OpenGL ES graphics. This is all working (mostly) how I would expect.

Now, I would like to implement a screenshot feature. For normal views, it seems that the standard practice is to create a new Canvas with a Bitmap and then draw to that Canvas using View.onDraw(Canvas).

I've tried using SurfaceView.draw(Canvas) in a similar fashion, but it always results in a blank (black) image.

I've also tried using the drawing cache with the exact same result.

View 3 Replies View Related

Android :: Draw A Bitmap Image?

Dec 2, 2009

Any one know about how to draw a bitmap image?...

View 6 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved