How to convert a raw file to png in Android? - android

I got an app, this app downloads many pictures, but i store them with my own format. This is because i dont want android system to show them in Gallery, so these are my own pictures.
I want to send them via email but firstly i want to convert them to .png of course.
How can i convert a File to png in Java(Android) ?

put .nomedia file in your folder. Or make your format just regular png but with extra custom header attached, so you will not have to convert, just write a copy with your header skipped

Related

Image loses transparency when using the ImageWorker class

So, I am loading icons from a server using the class found here:
https://developer.android.com/samples/DisplayingBitmaps/src/com.example.android.displayingbitmaps/util/ImageWorker.html
However, the images are not maintaining their transparency. If I view the image in my browser and view the details of the file, it recognizes the file as a PNG file and the transparency is there. It loses it when I load it onto my device.
The issue I believe is that the files do not have a .png extension and Android may not be able to detect that the files are PNG files automatically. This is my best guess, but I'm open to other potential solutions. If it is the lack of extension that is causing the problem, I do not control the server and I cannot get the extension added to the file names. Is there any manipulation I can do in the ImageWorker class to add the .png extension before it is sent to the ImageView and cached?
EDIT: If I save the file directly to the device and then display the image, it has transparency, even without a .png extension, so my assumption was incorrect. So, the question I have then, is why does it lose transparency when using the ImageWorker class?

How to select word in a pdf file

In my app I am using the library https://github.com/barteksc/AndroidPdfViewer for reading a pdf file. Now I want to select words from the pdf file, how will I do it?
What the library you're using actually does is to basically convert an PDF file into a Bitmap image so that it can be viewed and zoomed etc. Therefore you cannot select text or words from the PDF file, or the resulting Bitmap image for that matter.

How to get list of *.jpg files on server?

I'm trying to find simplest solution to make app where I can download all the images from the specifed, hardcoded directory.
So far, my idea is to get list of all .jpg images (since it will be the only image format in this directory) and put it in places on ViewPager so each image will be on seperate page.
Anyone has nice snippet or friendly library to use to make it happen?
You can create a txt file on the server in which the URLs of all images will be kept; then program your app to download this file first; then use input stream to read the URLs from the file and create a loop to download all urls until they finish, by checking if the input is null.
On server side either add the urls manually to the file or write a JavaScript to automatically write the URLs when uploading the image.

how to display .jpg image in android?

I am using .net web services and I am having list of folders and files. I am successful in retrieving list of files(.jpg Image, .pdf, .TIF) but can anybody let me know how we can open .jpg, .pdf, .tif or other files format which I am getting from web services. Is there any specific code to open particular format or we can use path (/) to open that particular file?
Thanks.
if you need to download and display an image, check my answer on this post, that is probably what you are looking for. Common extensions for displaying images in Android are .png and .jpeg, you will not be able to show a .pdf file using an ImageView. You can also use the method mentioned in my answer inside an AsyncTask to perform the download in background and then update your UI thread

Showing .rtf , .txt or .pdf files in web view of android?

i have three different kind of files ,
Document file
text file
pdf file .
while clicking button i need to render those file in webview of android, is it possible or not.
If any one know the solution means help me out.
Note: i need load those files from asset folder.
Thanks.
is it possible or not.
You can display a text file in a WebView via the text/plain MIME type. WebView cannot render PDF. I have no idea what you think a "document file" is.

Categories

Resources