Open gasstan opened 10 years ago
i have the same issue, how did you manage to solve it,if you could ?
up ? anyone knows how to work with the save ?
i have some problem!!!
saveToPictures is depricated.
use object of GPUImageView and capture as bitmap.
Bitmap bitmap = gpuImageView.capture();
now save bitmap as image in any of location.
for save image , use this :
private void saveImage() {
String FileName = System.currentTimeMillis() + ".jpg";
File path = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);
File file = new File(path, "GPUImage" + "/" + FileName);
file.getParentFile().mkdirs();`
FileOutputStream out = null;
Bitmap bitmap = mGPUImageView.getGPUImage().getBitmapWithFilterApplied();
try {
out = new FileOutputStream(file);
bitmap.compress(Bitmap.CompressFormat.PNG, 100, out);
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (out != null) {
out.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
}`
mGPUImageView.getGPUImage().getBitmapWithFilterApplied();
thows NullPointerException
java.lang.NullPointerException: Attempt to invoke virtual method 'int android.graphics.Bitmap.getWidth()' on a null object reference at jp.co.cyberagent.android.gpuimage.GPUImage.getBitmapWithFilterApplied(GPUImage.java:308) at jp.co.cyberagent.android.gpuimage.GPUImage.getBitmapWithFilterApplied(GPUImage.java:272)
package com.example.edgedetect;
import jp.co.cyberagent.android.gpuimage.GPUImage; import jp.co.cyberagent.android.gpuimage.GPUImageFilter; import jp.co.cyberagent.android.gpuimage.GPUImageSobelEdgeDetection; import jp.co.cyberagent.android.gpuimage.GPUImageView;
import android.net.Uri; import android.os.Bundle; import android.os.Environment; import android.app.Activity; import android.content.Intent; import android.view.Menu; import android.widget.Toast;
public class MainActivity extends Activity {
}
hi this is my cod but when i try to run it it show me an error: Android Runtime FATAL EXCEPTION: AsyncTask #2 An error occured while executing doInBackground() at java.lang.Thread.run(Thread.java:856) Caused by: java.lang.NullPointerException at jp.co.cyberagent.android.gpuimage.GPUImage.getBitmapWithFilterApplied(GPUImage.java:279)
when i move mGPUImage.saveToPictures to comment block it doesn't crash so i think ther is some problem ...can you help me ?