Skip to content

Error: No containing Triangle. #1

Open
@abhriyaroy

Description

@abhriyaroy

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions