ByoxCode / DrawView

Android view that allows the user to create drawings. Customize settings like color, width or tools. Undo or redo actions. Zoom into DrawView and add a background.
847 stars 156 forks source link

How to add backgound #11

Closed DanteAndroid closed 6 years ago

DanteAndroid commented 7 years ago

How to add a white board background? Default the background is transparent.

ByoxCode commented 7 years ago

Hi @DanteAndroid!

It isn't in the wiki, but you simply add in xml with:

android:background="@color/your_color_resource"

or with Java code:

drawView.setBackgroundResource(R.color.you_color_resource);

DanteAndroid commented 7 years ago

I have tried that method. But it only adds background when you draw, not in the actual bitmap.(When I save it, its background is black)

jd-alexander commented 7 years ago

Was this fixed? Can you now add a background that you can draw on top of ? Also is there a way to add a bitmap as the background?

ByoxCode commented 7 years ago

Ok, I actually working on that...

jd-alexander commented 7 years ago

Okay. Thanks.

ByoxCode commented 7 years ago

@DanteAndroid, @jd-alexander... Can you please check the new update? 1.2.6 and comment for close this "issue"

Regards!

DanteAndroid commented 7 years ago

@ByoxCode Sorry to say that this problem still exists in 1.2.6(background is black).

ByoxCode commented 7 years ago

@DanteAndroid the current version is 1.2.11, can you check this version please... I know what is the problem, but I can't remember if in this version doesn't has this error

DanteAndroid commented 7 years ago

@ByoxCode I don't know if I use it wrong, but the background is still black in 1.2.11

ByoxCode commented 7 years ago

@DanteAndroid can you explain more detailed your problem, maybe I have a bad idea of this.

DanteAndroid commented 7 years ago

Without android:background="@color/your_color_resource" or with it, I have a black background after save the draw in drawview to file.

Code here: https://github.com/DanteAndroid/TimePill/blob/master/app/src/main/java/com/dante/diary/draw/DrawActivity.java#L218 XML here: https://github.com/DanteAndroid/TimePill/blob/master/app/src/main/res/layout/fragment_draw.xml#L25

shalinpatel610 commented 6 years ago

There is one way to change the background color of an image.

First Solution:

Programmatically change each pixel from transparent to white(or any color). Add this code when you capture bitmap while saving.

Code here:


int width = bitmap.getWidth();
int height = bitmap.getHeight();
for(int x = 0; x < width; x++) {
     for(int y = 0; y < height; y++) {
           if(bitmap.getPixel(x, y) == Color.TRANSPARENT) {
                 bitmap.setPixel(x, y, Color.WHITE);
           }
      }
}
ByoxCode commented 6 years ago

Maybe this is because the image that you are trying to save is a PNG format, if you see in a gallery app the transparent background will be rendered in black color but is the background of the app.

Drawview Capture