How to crop circular area from bitmap in Android

After long brainstorming I have found the solution public Bitmap getCroppedBitmap(Bitmap bitmap) { Bitmap output = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Config.ARGB_8888); Canvas canvas = new Canvas(output); final int color = 0xff424242; final Paint paint = new Paint(); final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight()); paint.setAntiAlias(true); canvas.drawARGB(0, 0, 0, 0); paint.setColor(color); // canvas.drawRoundRect(rectF, roundPx, roundPx, paint); … Read more

Creating a blurring overlay view

You can use UIVisualEffectView to achieve this effect. This is a native API that has been fine-tuned for performance and great battery life, plus it’s easy to implement. Swift: //only apply the blur if the user hasn’t disabled transparency effects if !UIAccessibility.isReduceTransparencyEnabled { view.backgroundColor = .clear let blurEffect = UIBlurEffect(style: .dark) let blurEffectView = UIVisualEffectView(effect: … Read more

Java, how to draw constantly changing graphics

Here’s my major rewrite with the following noteworthy changes: I’ve separated the task of detecting pixel colours from the task of drawing I’ve replaced robot.getPixelColor(…) with robot.createScreenCapture(…) to fetch all 64 pixels at once, rather than one at a time I’ve introduced smart clipping – only what needs to be redrawn is redrawn. I’ve fixed … Read more

Fast work with Bitmaps in C#

You can do it a couple of different ways. You can use unsafe to get direct access to the data, or you can use marshaling to copy the data back and forth. The unsafe code is faster, but marshaling doesn’t require unsafe code. Here’s a performance comparison I did a while back. Here’s a complete … Read more

How do I position one image on top of another in HTML?

Ok, after some time, here’s what I landed on: .parent { position: relative; top: 0; left: 0; } .image1 { position: relative; top: 0; left: 0; border: 1px red solid; } .image2 { position: absolute; top: 30px; left: 30px; border: 1px green solid; } <div class=”parent”> <img class=”image1″ src=”https://via.placeholder.com/50″ /> <img class=”image2″ src=”https://via.placeholder.com/100″ /> </div> … Read more