#183
|
||||
|
||||
I tested in my Tattoo with Kalin 10.7 and works. For who wanna test the image needs to be changed to imagem.raw and the app will generate the imagem.jpg. Works only for 3MB quality images. (it's easy to adapt to other resolutions for Kalin).
http://www.megaupload.com/?d=2D2FRUWA Link for download of apk to install on phone. The code is very simple, for who want to change and make it better there is the main: RawToJpeg.java Código:
package com.image.rawtojpeg; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import android.app.Activity; import android.graphics.ImageFormat; import android.graphics.Rect; import android.graphics.YuvImage; import android.os.Bundle; import android.widget.TextView; public class RawToJpeg extends Activity { /** Called when the activity is first created. */ @override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); TextView tv = new TextView(this); try { FileOutputStream arqSaida = new FileOutputStream("/sdcard/DCIM/Camera/Imagem.jpg"); File f=new File("/sdcard/DCIM/Camera/Imagem.raw"); byte[] data = getBytesFromFile(f); YuvImage imagemYuv = new YuvImage(data, ImageFormat.NV21, 2048, 1536, null); Rect rect = new Rect(0,0,2048,1536); imagemYuv.compressToJpeg(rect, 100, arqSaida); arqSaida.close(); tv.setText("Sucesso."); } catch (FileNotFoundException e) { // TODO Auto-generated catch block tv.setText("Erro."); e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block tv.setText("Erro2."); e.printStackTrace(); } setContentView(tv); } public byte[] getBytesFromFile(File file) throws IOException { InputStream is = new FileInputStream(file); byte[] bytes; try { // Get the size of the file long length = file.length(); // You cannot create an array using a long type. // It needs to be an int type. // Before converting to an int type, check // to ensure that file is not larger than Integer.MAX_VALUE. if (length > Integer.MAX_VALUE) { // File is too large (>2GB) } // Create the byte array to hold the data bytes = new byte[(int)length]; // Read in the bytes int offset = 0; int numRead = 0; while (offset < bytes.length && (numRead=is.read(bytes, offset, bytes.length-offset)) >= 0) { offset += numRead; } // Ensure all the bytes have been read in if (offset < bytes.length) { throw new IOException("Could not completely read file " + file.getName()); } } finally { // Close the input stream and return bytes is.close(); } return bytes; } } |
#184
|
||||
|
||||
I tested in my Tattoo with Kalin 10.7 and works. For who wanna test the image needs to be changed to imagem.raw and the app will generate the imagem.jpg. Works only for 3MB quality images. (it's easy to adapt to other resolutions for Kalin).
http://www.megaupload.com/?d=2D2FRUWA Link for download of apk to install on phone. The code is very simple, for who want to change and make it better there is the main: RawToJpeg.java Código:
package com.image.rawtojpeg; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import android.app.Activity; import android.graphics.ImageFormat; import android.graphics.Rect; import android.graphics.YuvImage; import android.os.Bundle; import android.widget.TextView; public class RawToJpeg extends Activity { /** Called when the activity is first created. */ @override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); TextView tv = new TextView(this); try { FileOutputStream arqSaida = new FileOutputStream("/sdcard/DCIM/Camera/Imagem.jpg"); File f=new File("/sdcard/DCIM/Camera/Imagem.raw"); byte[] data = getBytesFromFile(f); YuvImage imagemYuv = new YuvImage(data, ImageFormat.NV21, 2048, 1536, null); Rect rect = new Rect(0,0,2048,1536); imagemYuv.compressToJpeg(rect, 100, arqSaida); arqSaida.close(); tv.setText("Sucesso."); } catch (FileNotFoundException e) { // TODO Auto-generated catch block tv.setText("Erro."); e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block tv.setText("Erro2."); e.printStackTrace(); } setContentView(tv); } public byte[] getBytesFromFile(File file) throws IOException { InputStream is = new FileInputStream(file); byte[] bytes; try { // Get the size of the file long length = file.length(); // You cannot create an array using a long type. // It needs to be an int type. // Before converting to an int type, check // to ensure that file is not larger than Integer.MAX_VALUE. if (length > Integer.MAX_VALUE) { // File is too large (>2GB) } // Create the byte array to hold the data bytes = new byte[(int)length]; // Read in the bytes int offset = 0; int numRead = 0; while (offset < bytes.length && (numRead=is.read(bytes, offset, bytes.length-offset)) >= 0) { offset += numRead; } // Ensure all the bytes have been read in if (offset < bytes.length) { throw new IOException("Could not completely read file " + file.getName()); } } finally { // Close the input stream and return bytes is.close(); } return bytes; } } I will go to try tomorrow, good work Última edición por Agedjus Día 01/02/11 a las 01:16:10. |
#185
|
||||
|
||||
I have tested it and works!!
Gallery app don't show the image but file explorer does. EDIT: Before connect usb drive to pc and disconnect, the gallery works full. Última edición por NewZa Día 01/02/11 a las 01:28:43. |
#186
|
||||
|
||||
Now is just wait Kalin for add the code to camera driver to get a direct jpeg file. The process and app is very simple. The biggest work is done by Kalin getting the image from camera and the best Rom for Tattoo. Always thanks for Kalin's job. |
#187
|
||||
|
||||
JODER
Great work @filipeferraz, ¿where were you all this time? XDDD P.D: Compis, ya tenemos photo en la tattoo sin pasar por el pc :OOO P.D2: Esperando a que Kalim meta ese código para tener gran ROM juasjuas |
#189
|
||||
|
||||
Que yo no he hecho nada, solo soy un mandao vuestro!!! Fijaos, yo puse mi ROM, añadí cuatro cosillas, uno de vosotros vió que salía la foto, puse cuatro cosillas, otro vió que era un raw y que hacia falta que modificara algo más, hice cuatro cosillas, y esa misma persona descubrió que el raw ya estaba completo, hice cuatro cosillas y podíamos hacer tantos raw como queríamos, ya ahora otro usuario se oferce a ayudarme con el código y solo tengo que compilar. Por cierto @filipeferraz ya ha creado el código, así que atentos que compilo y verificáis el resultado. filipeferraz Has already coded the new rutine, in minutes I will publish KalimGinger.10.10. Gracias a todos vosotros maestros.
__________________
__________________________________________________ __
CyanogenMod Nexus Devices Última edición por KalimochoAz Día 01/02/11 a las 10:48:18. |
#190
|
||||
|
||||
Wow...
y yo aún con la rom que viene con Vodafone... me tocará ponerme al día... Ánimo chicos! el siguiente paso será la radio? o al final quedó por imposible? bueno no pregunto más voy a leer por el foro a ver si saco algo en claro Lo dicho un excelente trabajo! ac6729 |
#191
|
||||
|
||||
Wow...
y yo aún con la rom que viene con Vodafone... me tocará ponerme al día... Ánimo chicos! el siguiente paso será la radio? o al final quedó por imposible? bueno no pregunto más voy a leer por el foro a ver si saco algo en claro Lo dicho un excelente trabajo! ac6729 Sent from my HTC tattoo using Tapatalk |
#192
|
||||
|
||||
Tiempo al tiempo
__________________
__________________________________________________ __
CyanogenMod Nexus Devices |
Gracias de parte de: | ||
Estás aquí | ||||||
|