Okay so i have pictures on server. I would like to display them in my app as a part of a ListView row. I've already made that and now I have a question regarding the dimensions of the pictures. Since its a bad idea to save my image at 48dp sizes on server (36x36, 48x48, 72x72, 96x96 ..) and then download specific one for specific DPI device. Is it possible to only save a 96x96 and then set it to an ImageView. ImageView width and width = 48dp, and scaleType= fitCenter. Are there any better ways? please help me
You're right that you need only one image size on a remote server like 96px and then in Android app just fit it to your needs like 48px.
The easiest way to implement it would be using Picasso library.
Of course, there is a Glide, with many extra features, (so it might look at the beginnig a bit complicated for beginners), but for the most of uses Picasso is a enough solution.
You can also try a new library developed by Facebook, called Fresco,if you care also about memory using but I highly recommend you a Picasso.
Here you would find nice tutorial for this library:
https://futurestud.io/blog/picasso-image-resizing-scaling-and-fit
If you would find more information about these three libraries visit this site
Fragmented Podcast - 005 – Image libraries for Android
You can use Glide or Picasso for that. It's very easy to implement.
Here is a guide that explains a little as the two libraries and do what you ask.
Related
I want to create a video from a series of images and add a transition between the images (e.g., fade in and fade out). I’m looking for a Java solution and not a C++ one (FFmpeg or anything else).
I checked out JCodec and MediaCodec, but none of those support image transitions.
Have you already tried it with OpenCV for Java? OpenCV offers almost everything you need for such a task. To the transitions you would have to worry about then manually with image blending. But that can be solved with OpenCV too. Just take a look at the documentary
EDIT:
It looks like the Java API lacks the appropriate module that can encode a sequence of images. You can fade images in any case. Take a look at the tutorial. This means you would have to crossfade the images with OpenCV and then use another API (e.g. jcodec) to make a video from the images you create.
I have three general questions regarding android's drawable folders.
Do i put different sized images in each of these folders, or will the images automatically scale themselves? As in, does android decrease the quality of the .bmp files automatically if placed in these folders?
When using the android design preview screen, will the appropriate image from the appropriate drawable folder be shown? If I have to make different sized images for each folder, I want to ensure that what i'm seeing in the design preview matches what is shown on other devices.
Lastly, do the drawable folders, if used, help to avoid the issue with failing to allocate memory for drawables on devices? I have had to scale my images down, and yet my college's phone still cannot allocate enough resources.
I couldn't find answers to these specific questions anywhere, so i'd really appreciate the help with these!
1) You don't need the different folders if you will put the same things in those folders. The designer/developer puts the resources that most adapt to that configuration.
2) You can select what kind of device you're previewing the design with (resolution and dpi), on the design tools. It will attempt to load the appropriate resource for that configuration.
3) Loading smaller images into memory may be helpful, as well as resizing them before displaying them (libraries like Picasso can do this out of the box), or you could be looking at a leak of some sort.
About your first question, you should create four different drawable folders in app>res in order to provide different devices (with different screen sizes and densities) more convenient images.
/drawable-ldpi For low density screens.
/drawable-mdpi For medium density screens.
/drawable-hdpi For high resolution screens.
/drawable-xhdpi For extra high resolution screens.
Android does not decrease the quality of .bmp files when they are allocated in those folders. You have to fill each folder with the correct sized images.
About second question, I am not sure whether the android design preview screen uses the correct images or not, but in a real app running on a phone, it will.
And third question: sorry, but not.
Good luck!
Ad 1 I always find it really helpful to load drawables to my project using Android Drawable Importer plugin. It will take care of loading appropriately-sized image into appropriate drawables folder.
Ad 3 If that works for you, maybe try loading images from server using tools like Glade or Picasso? That way you don't clutter your app with unnecessary resources, making it too heavy data-wise. Use a local drawable as placeholder only, in case there's no internet connection.
I'd also recommend using .png over .bmp format, .png are lossless and compressed, meaning your images can get significantly smaller while not losing quality.
You have to put images in different folders as per the image size. it will not generate automatically.
You can not select image for that screen. you can just select different screen sizes android studio will automatically use proper images for that.
For memory issue you can add this line in manifest :
android:hardwareAccelerated="true"
I'm working on a project that requires taking pictures and putting stickers on that photo. From what I understand this requires 3 main actions:
1. User should be able to resize the sticker.
2. User should be able to rotate the sticker.
3. And once done, the whole thing should be merged into a single image.
I'm having a really hard time starting this since I simply don't know where I should start. Should I find, or ever write my own code to do the above, or maybe try to use existing projects (but I was not able to find any open-source ones).
I've heard about Aviary, but it was recently purchased by Adobe, and it is now part of the Creative Cloud, which is quite vague regarding the price, if there is any.
Where should I start?
Thanks.
We at Img.ly have released an image editing SDK for Android as part of our PhotoEditorSDK product suite.
Users can resize rotate and adjust stickers out of the box and you can also add your own stickers and assets.
You can find a demo application here. You can use the library for free in your open source projects, but there is a license fee for commercial applications.
For Resizing the image add two buttons one for increasing the image size and the other for decreasing . Then in the set an onClickListener() for that buttons.
Inside that function first get the dimensions of the image using getWidth() and getHeight() , then use setWidth() and setHeight() to change the size.
for Rotating the sticker refer this link
After all these things use a canvas to save the sticker and image as a single file . for doing this refer this link.
In future do not combine all your queries in a single question.
I use these libraries and plugins in my projects
for cropping an image use this : Cropper
for rotating an image you can use this: PhotoProcessing
and at the end you can get the whole image in to a single image-view
I have no working experience of Java3d what so ever so I needed a quick information
where should I place images that I want to use in my project like the background of the panel
like we have Drawable folder in android.
and also I have seen that the background need the image as ImageComponent2d how to convert that retrieved image to that format
searched for it all around but no good tutorial was available
Any help is appreciated thanks in advace
Put the images on the run-time class path of the application (is the quick answer).
I have been developing Android application since 3 to 4 months. I am naive, But pretty much exposed to all of the fundamentals regarding application development on android. However I found really painful while developing application with lots of images, By saying images I mean one of my application has around 10 to 13 images(Small enough to accommodate screen size). The problem is I have to make different copies of it by making,
HDPI - High resolution support
MDPI - Medium resolution support
LDPI - Low resolution support
I have come up with an idea,
IDEA : My idea is to actually have only MDPI images in drawable folder, When my
application will installed first time, I want my application to detect what type of
resolution is supported by device? After knowing which resolution is supported one of my
built in method will either use a MDPI version(images), if handset supports it or else
it will scale up or scale down my images and stores into internal storage for future
reference. When user uninstall my application I will remove these images from internal
storage.
Now this idea has raised a question,
Question :
Whether this idea is feasible? and Programatically possible?
If it is, Should I be really concerned about one time computational overhead?
Is there any mechanism(third party) which can ease my problem? (I hate photoshop and scaling up and down all those images)
Any expert help or guidance will be a big favour!
Thanks in advance!
Krio
I dont really understand why you would do this. The system already basically does this for you. You dont have to specify different images for different display densities, the system just gives you the opportunity to so you can make your app look its best. If you only supply a single image the system will scale it appropriately for you based on the density of the handset.
As for help with scaling the images yourself for packaging, you could look at image magick. This is a powerful scriptable image manipulation tool. You might need to spend a bit of time getting up to speed with it, but I am sure you could write a script that you could reuse for all of your images after that to convert high dpi images to lower dpi ones by scaling down.
Take a look to this article. It describes how android handle directory names for resources. Also take a look a look to this - how android choose the best match for directory name. If you want to use the same resource for all dpis just place it in the default drawable folder.