I'm trying to load images to an array and can't figure out the syntax. I'm used to something like this in C#:
picture.Image = Image.FromFile(fileLocation);
That doesn't work here. Can anyone help me with this syntax, and any applicable imports I need to make. This is what I have:
public class Beards extends ActionBarActivity
{
Image [] beard = new Image[20];
String [] beardLocation = new String [20];
public void fillArrays()
{
for (int i = 0; i < 20; i++)
{
beardLocation[i] = "C:/Users/geoffoverfield01/AndroidStudioProjects/TheBeadery2.0/Images/Beards/pic_" + i + ".jpg";
}
for (int x =0;x<20;x++)
{
beard[x] = ImageIO.read(new File(beardLocation[x])); }
}
...
}
The library that allows me to use the ImageIO won't load.
I had to load some images for my Android project. This codes reads images and puts them into an Array.
ArrayList<Bitmap> bitmaps = new ArrayList<Bitmap>();
bitmaps.add(BitmapFactory.decodeResource(this.getResources(), R.raw.one));
bitmaps.add(BitmapFactory.decodeResource(this.getResources(), R.raw.two));
bitmaps.add(BitmapFactory.decodeResource(this.getResources(), R.raw.three));
bitmaps.add(BitmapFactory.decodeResource(this.getResources(), R.raw.four));
Image is sitting on /res/raw/
my images are named one.jpg two.jpg three.jpg four.jpg
Thanks.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With