Tile Bitmap - Bitmap As A Background Image In App

I'm trying to load a bitmap in android which i want to tile. I'm currently using the following in my view to display a bitmap: canvas. Drawbitmap(bitmap, srcrect, destrect, null)

I essentially want to use this bitmap as a background image in my app and would like to repeat the bitmap in both the x and y directions.

I've seen the tilemode. Repeat constant for the bitmapshader class but am unsure if this is to do with repeating he actual bitmap or to do with applying a filter to the bitmap.

View Full Post With 4 Replies

Related Forum Messages:

Please Follow Index to Quick Jump to the Message.

Draw Map From Textfile Onto Bitmap But Bitmap Is All Black

I'm trying to draw a map from a textfile onto a bitmap, but the bitmap is all black

First i load a textfile that looks like this (shortened):

0000000000 (200 width)
(120 height)

Where "1" is ground and "0" is a wall, 1 should be white and 0 should be black.


Posted On: Oct 12 at 16:05 . View Related Posts . . View 1 Replies .

Move A Path With A Repeating Bitmap Image In Droid

I'm currently writing an android side-scrolling game and am having trouble filling a path with a repeating bitmap image. I'm creating a path from a number of coordinates to make up the "ground" area. I have a character who is fixed in the middle of the canvas and screen and am moving the path to represent the movement of the character. I've been able to fill the path with a repeating image using a bitmapshader. Also i can move the path shape from side to side on the screen. However, the bitmapshader seems to be using a default origin of 0, 0 which means the shader is always drawing the ground repeating image in the same place. This means that even though the path is moving the ground repeated image never appears to move. Does anyone have any idea how to change the origin of the shader or know of a better way to fill the path with a repeating image?

Alternatively, can anyone suggest a better solution for filling a drawable shape with an image?

Posted On: Sep 15 at 16:29 . View Related Posts . . View 2 Replies .

Unable To Access Pixels Of A Bitmap Image On Droid / Solution For It

In short i am unable to access all the pixels of a bitmap image.

I have used an intent to fire the native camera app and returned a bitmap image to my application activity. The data is definitely a bitmap object and i am able to display, get the height/width etc and access some pixels using getpixel(). However when i use the values of getheight() and getwidth() i get an array out of bounds error. By trail and error i have found i can only access a reduced number of pixels of the image, for example with one image which returned a height and width value of 420, 380, i could also access 200, 100. I then do some image processing and used setpixel() on the original image. When i display the image it shows the, say 200, 100, processing pixels and the rest normal, therefore the pixels are obviously there and accessible by android but not by me. I have to spoken to other people who have also had this problem with images.

Does anyone know anything more about this, reasons? Or a work around?

Posted On: Nov 20 at 15:04 . View Related Posts . . View 2 Replies .

Part Of My Bitmap Image Missing When Written To External Storage / Why Is So

I want to send an image of a view to external storage so that it can be printed. The view is a grid made up of a tablelayout, tablerows and textviews. I write the view to the sdcard, then copy it to my hd using the ddms file-explorer screen. But when i look at it in ms paint, the image is only partially there.

I have tested this two ways.

When i used the xml version, the result was a small black square " no detail, no grid, nothing.

Next i created a textview programmatically, with text using settext(aaaŁ). The resulting bitmap had the correct color and size, but the text was missing.

Would someone please tell me how to get my view correctly written to external storage so that it looks like it does on the android screen? Code.

Posted On: Nov 10 at 7:00 . View Related Posts . . View 1 Replies .

Render Text Over A 48x48 Bitmap In Droid App

I'd like to know how can i render a text over a 48x48 bitmap in my android application, considering sometimes the text exceeds the bitmap width . In such cases i need to render only a part of the text followed by dots such that all fits the available width .code.

Posted On: Oct 18 at 5:41 . View Related Posts . . View 1 Replies .

Get Bitmap From An Uri

How to get bitmap object from an uri (i suppose i succeed to store it in /data/data/myfolder/myimage.png or file///data/data/myfolder/myimage.png i used both path) to use it in my application. But i failed to get it.

Posted On: Oct 7 at 8:43 . View Related Posts . . View 1 Replies .

Button Over Bitmap

I am a beginner android developer and i am trying to have a button display on top of the bitmaps i am outputting.

Here is what i have:

My activity sets this:


Main.xml is framelayout that i stuck a button on top of, that's it.

I guess my question is, how do i insert something into the main.xml as a "canvas" in order to paste my bitmaps to, but still have the button always on top regardless of how many bitmaps i draw?

Posted On: Oct 1 at 13:32 . View Related Posts . . View 1 Replies .

Copypixelsfrombuffer() To Particular Bitmap Offset

I am working on an android application that deals with graphical operations in native code on a shared memory buffer. I have made functions to call my native code from java using jni, and my native code uses the jni api to call java from native code. Since copying large arrays of pixels has a significant effect on performance, i need to avoid it as much as possible.

The android documentation for the bitmap class talks of two ways for copying pixels onto the bitmap internal buffer:

Setpixels(int[] pixels, int offset, int stride, int x, int y, int width, int height) replace pixels in the bitmap with the colors in the array.copypixelsfrombuffer(buffer src) copy the pixels from the buffer, beginning at the current position, overwriting the bitmap's pixels.

The problem with the api documentation is that it is very vague about what is happening behind the scenes when you use those functions. However, it is mentioned somewhere that copypixelsfrombuffer() copies pixels directly without any internal color format conversion, as opposed to setpixels() which will in all case do that conversion even if the original pixels are in the target pixel format. Obviously, that is not something i want, since the pixels in my buffer are in the good format already.

Now, copypixelsfrombuffer() looks very nice since it won't do that conversion, but the documentation does not talk of how to copy pixels from a buffer to a particular offset in the target bitmap. Oops, that is something very important, since i don't want to copy the entire buffer every time, but only a region on it. Yes, the documentation says that it is going to copy from the current position in the source buffer but nothing is said about the destination buffer. Setpixels() does the unnecessary conversion, but allows you to specify an offset in the destination buffer.

So, i am stuck between:

Copying only the region that i want at the cost of having pixel conversion


Avoiding pixel conversion at the cost of copying the entire buffer every time

To get an idea, i may have a buffer representing a 1024x768 screen, with an invalid region that goes from (300, 300) to (400, 400).

If i copy only the region i need to update, i can copy and convert 100*100 pixels or copy without converting 1024*768 pixels. A 100x100 invalid region is small and only a particular case, most invalid regions would take a much larger portion of the buffer. Both methods have very negative effects on performance.

Does anybody have an idea on how i could copy pixels from my buffer to a particular offset on the target buffer, without forced pixel conversion? That would be the best of both worlds, and i don't see why it does not appear to be available.

Posted On: Nov 4 at 18:33 . View Related Posts . . View 1 Replies .

How To Convert A Drawable To Bitmap

How can i convert a drawable to a bitmap?
I would like to set a certain drawable as the device's wallpaper, but all wallpaper functions accept bitmaps only (i cannot use wallpapermanager - i'm pre 2. 1).
Also, my drawables are downloaded from the web and do not reside in r. Drawable.

Posted On: Jun 14 at 7:46 . View Related Posts . . View 2 Replies .

Bitmap Allocation Weirdness

I'm having some trouble understanding why this code:


Posted On: Aug 24 . View Related Posts . . View 7 Replies .

Merge Bitmap Overtop Of Another

Ok so i have sort of a picture frame type bitmap and a picture bitmap so think of it like this i have a 64x64 frame image where (5, 6) to like (56, 54) is where the picture should be, how can i merge the picture bitmap into the frame bitmap with those bounds and make it one bitmap? Ive been searching everywhere to no avail.

Posted On: Jul 13 . View Related Posts . . View 2 Replies .

Bitmap Encoding Is Always Lossy

I have a case where i need to retrieve the bitmap from an imageview and write that bitmap to a file so that i can later on retrieve it back again and set it on a new imageview. I do this using bitmap.compress() method. However, the problem is that after i do this about 5 times, the quality of the bitmap degenerates badly. The format i use for the bitmap.compress() is jpeg with the quality as 100. In my mind 100 would mean no compression of the source bitmap and that the bitmap should be lossless, but it doesnt seem to be that way. Is this a bug or is this how it is meant to be?

I want a lossless compression and i tried to use png as the format with bitmap.compress() but that doesnt seem to work either. After digging around i found out that png encoding is not supported, which basically leads me to believe there is no way of storing (in a lossless way) a bitmap isnt that weird? How else can i achieve this lossless writing of bitmap to the file. Why doesn the bitmap class simply have an encode() method to write the bitmap in memory as is?

Posted On: Jun 12 2009 . View Related Posts . . View 4 Replies .

Overlaying Text On Bitmap

I'd like to know if there is a way to get bitmaps corresponding to a glyph of a font. I have a bitmap and was looking for an api that would let me overlay some text on top of it and give me the output bitmap. I could not find any such api so was thinking of doing a custom implementation.

The issue is that i couldn't find a way to get the bitmaps corresponding to the glyphs either. Is there api that i may have overlooked or some round about way to achieve this?

Posted On: Aug 14 2009 . View Related Posts . . View 2 Replies .

Why Can't Retrieve Compressed Bitmap

Here is what i do


And to retrieve it


Posted On: Jul 22 at 1:22 . View Related Posts . . View 1 Replies .

Display A Bitmap In A Editbox In Droid

I have two bitmap images . And i need to merge the bitmaps with precise positioning of one bitmap over other and get a resultant bitmap (which is combination of both)

And the resultant bitmap is a font character and i want that bitmap to be displayed in a edit box where i am inputting text.

Posted On: Jul 30 at 5:43 . View Related Posts . . View 1 Replies .

Write Bitmap To Data Folder?

I can't figure out how to do this. Looking around online got me this code.

I get no errors, but i also get nothing written to my sd card. Any ideas?

Posted On: Mar 5 . View Related Posts . . View 2 Replies .

Convert Bitmap To Sepia In Droid

Is there any way to convert a bitmap to sepia?
I know to convert to grayscale is to set the setsaturation in colormatrix.
But what about sepia?

Posted On: Nov 10 at 4:09 . View Related Posts . . View 1 Replies .

Start Activity With A Bitmap Attached

I have this code.

Which successfully launches an messaging app on android.

But how can i attach a bitmap object when launching the intent?

I have read, the closet thing to what i need is extra_stream, like this:
Intent2. Putextra(intent. Extra_stream, _uri);

But my case, i have a reference of bitmap object, not an uri of an

Please tell me what can i do to attach a bitmap object?

Posted On: Jun 25 09 at 19:57 . View Related Posts . . View 2 Replies .

Stamp Bitmap Along A Line In Droid

Is there any easy way to stamp bitmaps along a line in android? I've found the pathdashpatheffect class but that only allows paths to be stamped, rather than bitmaps. It seems like it should be possible, but i'm not sure where to start.

I could obviously just draw bitmaps along the line, but it seems to me like that would be a bit more resource intensive, especially because i would not be doing it in native code.

Any help or suggestions?

Posted On: Aug 8 at 3:23 . View Related Posts . . View 1 Replies .

Add Threshold To Bitmap Images

I have a question about adding a threshold images into bitmap images, can this be possible with the android sdk, if not can anyone here generate the algorithm for that to add threshold to images.

Posted On: Aug 24 2009 . View Related Posts . . View 4 Replies .

Lost Of Quality With Bitmap Rotation

My program stacks several images, with a certain angle of rotation. The code works, but the image loses of the quality in spite of the dithering during the rotation (except on right angles 90, 180, 270!). The image is a black circle and there are peaks which appear with the rotation which are not visible with the same rotation on gimp or photoshop. I uses the matrix method, but i also tried with the canvas. Rotate method, same result.

Posted On: Nov 19 . View Related Posts . . View 2 Replies .

Copy Pixels From One Bitmap To Another Shaped Like A Circle

I am using setpixel and getpixel functions but they are using matrices which is naturally rectangle. I am trying to copy pixels shaped like circle !

Update :
Now i am using this but i hope there is something more efficient than this one code.

Posted On: Oct 28 at 16:43 . View Related Posts . . View 2 Replies .

How To Convert Camera Preview To Bitmap Without Use Take Picture

How can i convert the camera preview to a bitmap without use takepicture ? The goal is to analyze the colors present inside the current preview. When i try to create bitmap (50x50 pixels of the current view) the result view is green with black lines. Apparently the preview uses the yuv color and i have to translate it in rgb to create my bitmap. I'm using a method found decodeyuv on this group: Fr/group/android-developers/browse_thread/thread.

Posted On: Nov 18 2009 . View Related Posts . . View 4 Replies .

Draw Antialiased Bitmap Along With Transformation Matrices

How to draw antialiased bitmap along with transformation matrices. I use matrix to rotate and scale a bitmap and then draw it using canvas. Drawbitmap

But the bitmap after the transformation looks ugly and aliased. I tried using the paint. Antialias(true) and passing it to drawbitmap function. It doesn't seem to work.

Should i set anymore parameters?

Posted On: Mar 3 2009 . View Related Posts . . View 3 Replies .

Adding A Bitmap Texture To Non Rectangular Item

I have a widget which looks like this:every cone is a "touchable element". Now i want to put a bitmap texture above each cone. However, bitmap images are all rectangular, so a bitmap texture above one cone would interfere with the bitmap texture above another cone. I'm wondering what is the best solution to this approach. Should i just create an image which fits (as a rectangle) exactly above the cone and make the non used areas transparent?

A second question is, how do bitmap textures work with stretching? Because this whole circle draws itself to fit the whole screen size, while bitmap textures are pretty much one size.

Posted On: Oct 1 at 10:52 . View Related Posts . . View 1 Replies .

Add Touch Capabilities To A Simple Bitmap

How can i add touch capabilities to a simple bitmap?

I've tried to create a wrapper class for a bitmap, which implemented ongesturelistener, but it didn't work.

I want to avoid extending view class to achieve this.

Posted On: Jun 25 at 17:38 . View Related Posts . . View 2 Replies .

Bitmap Crashing Upon Going Back And Re-entering Activity / Fix It?

I'm not sure what is causing this. I have two activities, first has a button that goes to the second. The second creates a bitmap object, assigns it a picture from the sdcard and loads it into an imageview.

Problem is when i go into the second activity, then press the back button, and then go back into the second activity, it crashes. I have no clue why. I did an extensive google search but to no avail.

I can post the source code if you want.

I got this from the logcat:
"E/dalvikvm( 4869): unable to open stack trace file '/data/anr/traces.txt': permission denied"

I'm not sure how to get the stack trace.

Posted On: May 13 at 14:27 . View Related Posts . . View 1 Replies .

Convert Raw Frame Buffer Pixel Data To A Bitmap?

I am trying to convert a byte array containing raw frame buffer pixel data (height 480 * width 320 * bytes per pixel 2 ) in to a bitmap. To do this using bitmap. Setpixels, which needs an integer array of colors, i need to convert the 2 byte (rgb_565) data for each pixel in to an integer. This is expensive since it needs to be done for (480*320) pixels.

Is there a more efficient way of doing this conversion?

Posted On: Jun 8 2009 . View Related Posts . . View 2 Replies .

Unable To Display Complete Bitmap In Droid Using Canvas / Get Full To Show

I am using following ondraw method to display bitmap on screen.code.

Image is displayed on the screen but some part because android screen is small
How can i display complete image in whole android screen?

Can i set scaletype of image to fitxy in canvas ?


Can i add android layout image to this canvas so that i could set fitxy property or image there as i have commented the code?

Posted On: Jun 10 at 9:47 . View Related Posts . . View 2 Replies .