Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getBitmapWithFilterApplied() hangs my mobile. #19

Closed
javierpuntonet opened this issue Mar 18, 2013 · 15 comments
Closed

getBitmapWithFilterApplied() hangs my mobile. #19

javierpuntonet opened this issue Mar 18, 2013 · 15 comments

Comments

@javierpuntonet
Copy link
Contributor

Hi,

getBitmapWithFilterApplied() hangs my Samsung Galaxy Ace after called.

@jamieomatthews
Copy link

I'm not 100% sure, but I've been looking into how to do live processing of images, using the pixel buffers. As I've been looking into it, several people have said that doing offscreen rendering can not work on certain devices.

This is because some devices (I believe it was pre android 3.0) drivers do not support multiple active GL contexts across processes. I would try your code on a newer android phone and see if it works. If so, there might not be anyway to fix this for now, unless a better algoritm is suggested. Otherwise, perhaps there is an underlying issue

@javierpuntonet
Copy link
Contributor Author

I have solved it creating a Bitmap from GLSurface in "onDrawFrame". But I have discover another problem, the resulting Bitmap depends on GLSurfaceView width and height. On my Samsung Galaxy Ace the resulting Bitmap is 320x240, but in my LG Optimus 3D is 800x480.

I have solved the last problem forcing "onMeasure" to be 800x800.

Sorry about my english.

@pboos
Copy link
Collaborator

pboos commented Mar 20, 2013

Thank you for opening this issue. This was something that was concerning me when I built GPUImage for Android. Reading it in onDrawFrame seemed the nicer way, but I did not like the low quality it will return on some phones.

the onMeasure solution seems to be an interesting way. Maybe have it normal size, then quickly measure it with different size when storing. Sadly loaded image is pretty small too. I resized it to screen size to make sure there won't be memory problems. That needs to be done nicer.

I do not know when I will have time to fix this. But if anyone sends a pull request, that would be the fastest way :)

@javierpuntonet
Copy link
Contributor Author

Thank you pboos, setting onMeasure in 800x800 (and 800x800 in layout too) my images with a resolution of 800x600 are working perfectly. I can save it in Bitmap and upload to a server, with perfect quality.

But is a very dirty solution and very slow, I hope that you can find a solution to this problem. Thank you.

@jamieomatthews
Copy link

Would you mind posting some of your code? I believe I am trying to solve a very similar problem

@javierpuntonet
Copy link
Contributor Author

Hello Jamie, I don't know how to make a gist. I could send you a copy of my code to your email.

@jamieomatthews
Copy link

Sure, that would be awesome. Jmatthews08@gmail.com . If I come up with any optimizations, I will post them here!

@javierpuntonet
Copy link
Contributor Author

I have send you and email with the code and an example code.

@pboos
Copy link
Collaborator

pboos commented Mar 21, 2013

Could you share it as a gist? Just go to https://gist.github.com/, login with github, share and post url here :). Really easy :). Than I will try to find a way to integrate it :)

@jamieomatthews
Copy link

Ok, here is a gist with his updates. I copied over some stuff that I didn't have about scaletype, but in retrospect I dont think that had anything to do with this particular change. @javierpuntonet I also changed the name of the callback class, to be in english.

https://gist.github.com/jamieomatthews/5216018#file-gpuimagechanges

@javierpuntonet
Copy link
Contributor Author

Ok, no problem Jamie.

@pboos
Copy link
Collaborator

pboos commented May 7, 2013

Thank you very much for the code provided above. With the given idea i now changed the saving process to getting the Bitmap from the same gl context through during onDrawFrame. As well I added resizing in there. Became kind of ugly, but it works fine so far. I hope this solves the problems :)

@javierpuntonet
Copy link
Contributor Author

Brilliant work pboos, works perfectly!

@javierpuntonet
Copy link
Contributor Author

I think this issue can be closed. The new capture method works perfectly.

mediavrog pushed a commit to mediavrog/android-gpuimage that referenced this issue Aug 1, 2013
…. Resize view for capturing picture of bigger size.

Closes cats-oss#19
References cats-oss#31
@stonyz
Copy link

stonyz commented Dec 19, 2014

I tested the latest code pulled from the master branch, and found
bitmap = gpuImage.getBitmapWithFilterApplied();
still very slowly (cost about 5s), especially when the image is big;

My testing code is,

    GPUImage gpuImage = new GPUImage(this.getActivity());  
    gpuImage.setImage(bitmap);  
    gpuImage.setFilter(groupFilter);  
    bitmap = gpuImage.getBitmapWithFilterApplied();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants