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

Error: No containing Triangle. #1

Open
abhriyaroy opened this issue Oct 29, 2016 · 0 comments
Open

Error: No containing Triangle. #1

abhriyaroy opened this issue Oct 29, 2016 · 0 comments

Comments

@abhriyaroy
Copy link

abhriyaroy commented Oct 29, 2016

Hello,
Firstly, I am a huge fan of your work. It's just amazing and the best part about it is that its faster than other methods and that it can run on android without native. A huge thank you, for your effort.
I am implementing your method in my app to generate lowpoly wallpapers. It works absolutely fine when I use a bitmap which is scaled to 1440x1080 but the problem in that is the images (which are of different sizes) come out with a bad aspect ratio. So in order to scale them properly, I use two methods -
public int getScreenWidth() { int densityDpi = (int) Math.floor((double) width * (double) getScreenHeight() / (double) height); return densityDpi; }

and
public int getScreenHeight() { DisplayMetrics metrics = getResources().getDisplayMetrics(); int densityDpi = (int) (metrics.heightPixels * 1.2); return densityDpi; }

After that, I scale the bitmap to getScreenWidth()xgetScreenHeight(). But the problem in this case is that it gives me java.lang.IllegalArgumentException: No containing triangle

Here is the full stack trace-
** java.lang.RuntimeException: An error occurred while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:318)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354)
at java.util.concurrent.FutureTask.setException(FutureTask.java:223)
at java.util.concurrent.FutureTask.run(FutureTask.java:242)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:243)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:761)
Caused by: java.lang.IllegalArgumentException: No containing triangle
at LowPoly.core.DelaunayTriangulation.Triangulation.delaunayPlace(Triangulation.java:192)
at zebrostudio.wallr100.DetailActivity$12$2.doInBackground(DetailActivity.java:521)
at android.os.AsyncTask$2.call(AsyncTask.java:304)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:243) 
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133) 
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607) 
at java.lang.Thread.run(Thread.java:761) **

Now the line at which the app crashes is - dt.delaunayPlace(new Pnt(width - 1, 1));

*What I have tried - *
For different devices with different display sizes and different wallpapers with varying dimensions, the app cashes at one of the following lines -
dt.delaunayPlace(new Pnt(1, 1)); dt.delaunayPlace(new Pnt(1, height - 1)); dt.delaunayPlace(new Pnt(width - 1, 1)); dt.delaunayPlace(new Pnt(width - 1, height - 1));

Please note -
I cannot extract the image from a imageView, because the wallpaper would be of small dimension then and will get pixelated on setting it as wallpaper.

Thank you.

@abhriyaroy abhriyaroy changed the title No containing Triangle. Error: No containing Triangle. Oct 29, 2016
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

1 participant