I'm trying to get the image srouce of an ImageView - java

I'm doing a card matching game at the moment and I am fairly new to Android studio so forgive me if this is a stupid question. I'm at the point where i am trying to compare two image views to see if they have the same image source.
While i'm able to do this to set the image source
ImageView obImg = findViewById(R.id.ivCard2);
obImg.setImageResource(R.drawable.AceS);
After searching around for a while i'm not sure how to get that image resource
//there's nothing simple like
obImg.getImageResource;
//and this seems to crash my program
obImg.getTag();
Thanks for everyone's help in advance

Related

Best way to detect corners of a plaque and reference object (Java, Opencv, Android Studio)

first of all English is not my main language. So I'm sorry for any mistakes and also this is my first time using StackOverflow.
About my problem: I'm doing a research project at my college, where I have to create an app that is able to analyze an image of a plate and its reference object. And return the width and height of that plate using a picture taken with the app. I joined the project after it started so the app has to be made in android studio using java. The thing is, that my major is not in computer science. So maybe I don't have enough bag of knowledge, to know where to look and would like to know if you have tips on what I have to search for or anything that could help me .
Right now I'm doing the whole usual process of getting an object contour (threshold, blur, etc etc) and I have a really good threshold image.
I'm getting the contour of the plaque just fine but I'm having trouble with the reference object (the A4 sheet). I'm currently using Imgproc.approxPolyDP and the sheet proportion to ensure that the outline is that of the sheet and not some other outline of the plate, but if I can make it work for a specific photo it doesn't work for the real-time picture on the app.
So do you guys have any tips? Or should I talk to my teacher for him to make some concessions? I thought about making an interface where the user could select the right contours and then calculate the height and width values ​​but my teacher is very difficult to accept changes in the project.
Thanks in advance!

How to draw curved text in Android

I'm trying to build a text editing app that allows the user to edit text using different fonts, colors, sizes, rotations, etc. I'm working on a feature that is supposed to curve the text but I've got no clue how to do it. I found this StackOverflow post HERE and searching through the comments, I found this post HERE but for what I'm trying to achieve, that is how I want it to end up. What I want it to do is start as a normal line of text and then based on the value of a seekbar I want it to curve, until it reaches the MAX value at which point it's in a circle (as seen in the second link). If you can help me figure out how to do this I would really appreciate it. I figure it's going to use path.addArc or something like that but I'm not sure.
Thank you
PS
I'll post the images below just in case you don't want to go look at the links
You can draw your circle text in your custom view, use canvas function drawTextOnPath(String text,Path path, float hOffset, float vOffset,Paint paint), and then construct the path by yourself requirement.

Is there a way to show a gif inside a SurfaceView?

I created a surfaceVeiw with a custom Background and a little figure. So far so good. Is there a posibility to show a Explosion (not as one picture but as a little video) when the figure collides with objects?
I already created these objects so the only thing I need to know is, how I can implement a method to show such explosion.
Do you need some code to help me?
You can use glide libray for showing gif in android
Glide.with(context)
.load(imageUrl)
.asGif()
.placeholder(R.drawable.loading_gif)
.into(imageView);

Libgdx: random image, like slide show for a loading screen

I wanted to create an loading screen which will present a random image and switch/transition to the other. I would just like to ask for any suggestion on how i should properly implement this loadscreen with random images?
There are 2 methods as I can remember right now.
In first method you have to load those random images and while AssetsManager loads your assets , just pick any image on random and display it for some period of time and then switch to some other image.
In second method if the random images are loaded using assets manager only then use method
assets.manager.isLoaded(fileName) to know if your random image is loaded or not. If its loaded then draw it else draw previous image only.
And Essa Rebano , i have repeatedly told u in your previous questions also to provide more information . Even in this question you should have posted you research work that you have done for this problem and where you are stuck in .. It becomes difficult for us to know how much you know and wot where exactly the problem lies. I hope u understand . If there is anything you are not able to understand in above sol. then you are most welcome to ask :)

Image Importing & Painting in Android Java

Recently, I have taken java and now am heading into Android Java.
However, Android has quite a few different things to tackle when programming.
So as my title says, how can I Import an image from my /res folder and paint it on the screen?
Usually, I would do something like this.
import java.awt.*
And in main class
public Image img;
And in public void paint
case CASE:
g2d.drawimage(...)
break
This doesn't seem to work in android.
Can someone explain how you could import and display images in a location in android?
It's great to see someone new trying out android development.
As for your question you could use and ImageView though if you are looking for something more dynamic then you should use a canvas. It will allowing for drawing images and animations.
I highly recommend you check out these tutorials:
Here is a list of 200 android tutorials that really helped me start out. Though some go over features that are now deprecated.
Android Tutorials
Here is where the videos start going over basic game making. It goes from video #61 to about #80.
Android Tutorial #61
These videos can help you draw a basic image or make a simple game if that's what your looking for. Though I recommend you go learn as much of the basics as you can before going into anything really complicated.
Don't overextend yourself with something to difficult to begin with because it migh leave your frustrated with the entire android concept.
Hope this helps.
u can add images/picture in the res/drawables
http://developer.android.com/guide/topics/graphics/2d-graphics.html
Also different devices use different resolutions
http://developer.android.com/guide/practices/screens_support.html
use a ImageView widget to display the image
image = (ImageView) findViewById(R.id.imageView1);
image.setImageResource(R.drawable.android);
this is assuming you have a file name android.png|jpg|gif etc in your drawable folder. If you want to use a image that is selected at runtime check here. How to set the image from drawable dynamically in android?

Categories