Using Texture in ImageView - android

I am pretty new to android native. I use game frameworks for making games.
Recently I was building a app that has an imageView. I can attach an drawable to it very easily. But now what I need is a dynamic image.
For example consider a square image.
Divide it into 4
1st half is filled with red,2nd is filled with green,3rd with yellow and 4th with blue.
In gameframeworks we can create a texture on the fly and use it. Is there any such option in android native?

Related

Taking a snippet of a photo and comparing the colour?

So, I wanted to do this in preferably Ionic / Android. I want to take a picture of something using the Camera. On the preview four boxes will appear (as an example) you then take the image and the colours within the boxes are then compared against say an array I’ve fetched from an API.
Basically in short a way to select colours within a specific area/s defined and compare them against a set of colours
I figured out a solution using Canvas HTML. You can use a click event on the canvas to grab the pixel colour using the getImageData() method. Android also has a canvas (although will attempt it in Ionic before looking at Android)

upload image and draw rectangles using only one ImageView

Can I upload a picture (in a ImageView) and draw rectangles using the canvas in the same ImageView? all the examples I've seen so far used two. I wonder if you can use only one? if so, how?
If you are new to android.
Open android studio, .
File ->New->import Sample ,
search for image.
Choose basic render script, this will give you basics of image handling.
However for your usage, you can simply create a view with border and add imageview inside it.

Android - Selective focus on a bitmap

I'm currently able to blur a whole bitmap (by resizing it down than up for example).
The effect I'm trying to accomplish is a selective blur : the result bitmap would be blurred, minus a round / oval part of it which would still be sharp :
The difficult part is that the sharp oval part could be smaller or bigger, and should be movable (its coordinates aren't always the center of the original bitmap).
I already found a solution, but I don't think of it as a good performance wise solution :
Copy the original bitmap into two different bitmaps (background and foreground)
Blur the background one
Crop the foreground one into the desired shape (round or oval)
Erase the borders of the foreground a bit (to avoid a too sharp difference between foreground and background images)
Put back the two images together
Export it as a bitmap
One another solution could be to recreate a blur algorithm which would run through every pixel of the original bitmap and apply an amount of blur higher or lower depending on the portion of the bitmap.
I finally decided to follow my first idea, using #DerGolem links. Here is the updated version of the chart :
The algorithm is quite simple:
We create two copies of the bitmap : the first one will serve as the background, while the other one will be used as the sharp part of the picture. To avoid the second one to be too sharp, we'll use a prepared mask (stored in the drawables folder)
We blur the first one as much as we want
We apply the mask to the second bitmap
We create a bitmap from those two previous steps
I created a sample demo application, hosted on BitBucket. You can clone the project and try it, the performances are much better than what I expected!
In order to achieve this, I used the following resources:
RenderScript to blur the background, much better than resizing the image down and up : 1, 2
Understand Porter/Duff
As said in the project's readme, the provided code is far from being perfect, but it works.

How can I manipulate and display SVG graphics on Android?

I would like to draw technical illustrations in my Android app.
I have images with shapes, and I have to change the size of those shapes based on input data. Thought that I could save those images as SVG, then I could manipulate the size of the shapes in it. For example, I would like to take a with a specified ID, and change its width/height.
There're great SVG display libraries for Android, but I haven't found one which can also manipulate the graphics.
Do you know any library which can do this?
If not, how else should I draw my illustrations?

Creating custom sprites

I want to create my own sprite sheet from a single image i have by modifying the image(like changing the position of the leg).For example lets say i have an image of a man running.I want to create a sprite sheet from this single image.What software do i use for this.From want i understand texturepacker and other such softwares enable you to edit the spritesheet.But as of now i have no images in the sprite sheet except for one.
Another question i had was that lets say i want to create my own sprites,how do i do this.(Are there softwares available for this)
There is simple program to create spritesheets from swf animation, SWFSheet, written by Keith Peters. Animation can be created in Flash or any 2d animation editor which supports export to swf like KToon, SWF Quicker, Giotto and so on.
And maybe single-framed bitmap can be animated using morphing?

Categories

Resources