Skip to main content

Posts

Showing posts with the label bitmap

How to make glow effect around a bitmap?

The following code is what I got so far. However, there are 2 issues: I want both inner and outer glow effects, which looking similar to the Photoshop's blending options. But I only managed to make the outer glow, if I set BlurMaskFilter.Blur.INNER or other value, the whole image is blocked, instead of just edges. Despite I set "FF" as alpha value, the glow color is still very dark. Bitmap alpha = origin.extractAlpha(); BlurMaskFilter blurMaskFilter = new BlurMaskFilter(5, BlurMaskFilter.Blur.OUTER); Paint paint = new Paint(); paint.setMaskFilter(blurMaskFilter); paint.setColor(0xffffffff); Canvas canvas = new Canvas(origin); canvas.drawBitmap(alpha, 0, 0, paint); return origin; Source: Tips4all

Android take screen shot programatically

First off i am writing a root app so root permissions are no issue. I've searched and searched and found a lot of code that never worked for me here is what i've pieced together so far and sorta works. When i say sorta i mean it makes an image on my /sdcard/test.png however the file is 0 bytes and obviously can't be viewed. public class ScreenShot extends Activity{ View content; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.blank); content = findViewById(R.id.blankview); getScreen(); } private void getScreen(){ Bitmap bitmap = content.getDrawingCache(); File file = new File("/sdcard/test.png"); try { file.createNewFile(); FileOutputStream ostream = new FileOutputStream(file); bitmap.compress(CompressFormat.PNG, 100, ostream); ostream.close(); } catch (Exception e) { e.printStackTrace(); } } } Any h

Determine width and height of a bitmap

I am using the following code snippet to create a bitmap with text. Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG); paint.setStyle(Style.FILL); paint.setColor(fontColor); paint.setTextSize(fontSize); canvas.drawText("My Text", x, y, paint); Here's the catch. How do I determine the size of the Bitmap to use in the canvas beforehand? For instance if I want a bitmap with "Hello World!" on it, I want to find the width and height of it even before I draw the text on the canvas.