Coder Social home page Coder Social logo

Comments (9)

Odaym avatar Odaym commented on July 17, 2024

Just to be clear, I try this with the press of a button after I've drawn some lines I call drawableView.obtainBitmap(), that's it.

from drawableview.

PaNaVTEC avatar PaNaVTEC commented on July 17, 2024

I'll check it asap. 👍

from drawableview.

PaNaVTEC avatar PaNaVTEC commented on July 17, 2024

Hi, @Odaym show me your code to obtain the bitmap, I'm trying saving the bitmap with the sample and is working Ok.

from drawableview.

Odaym avatar Odaym commented on July 17, 2024

What I'm trying to do with this is allow the user to draw something over an ImageView with a picture loaded in the Activity. Upon pressing Save, I grab the bitmap from drawableView and I grab the picture loaded into the ImageView and I combine them and save them as one image.

For now, the code below stores the bitmap from the drawableView onto the device and loads it instead of the picture in the ImageView (instead of the picture that was there), this is just for testing whether the bitmap will be saved or not.

And the file I linked to above I got it from going to the device and seeing the saved file of the bitmap, but it was empty

fabActionUndo.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                Picasso.with(Test_Activity.this).load(new File(storeImage(drawableView.obtainBitmap()))).into(tstImageView);

                //sometimes I call clear just to see only the imageview without the stuff I've just drawn on the bitmap. Whether it's there or not, same outcome happens with empty image file
                //drawableView.clear();
            }
        });

private String storeImage(Bitmap image) {
        File pictureFile = createImageFile();
        if (pictureFile == null) {
            Log.d("TAG",
                    "Error creating media file, check storage permissions: ");
            return "";
        }
        try {
            FileOutputStream fos = new FileOutputStream(pictureFile);
            image.compress(Bitmap.CompressFormat.PNG, 90, fos);
            fos.close();
        } catch (FileNotFoundException e) {
            Log.d("TAG", "File not found: " + e.getMessage());
        } catch (IOException e) {
            Log.d("TAG", "Error accessing file: " + e.getMessage());
        }

        Log.d("IMAGE", "PATH OF DRAWABLE VIEW IS : " + pictureFile.getAbsoluteFile());

        return pictureFile.getAbsolutePath();
    }

from drawableview.

Odaym avatar Odaym commented on July 17, 2024

Chris, the feature/limit_canvas_size branch included the fix for this issue. I didn't change any code at all from what I pasted above when I ran the project. I just wanted to test the canvas height and thought I'd also try the obtainBitmap() cause you said it was working fine. So I found it working fine, strangely

from drawableview.

PaNaVTEC avatar PaNaVTEC commented on July 17, 2024

Ok, re-open this if the issue returns.

from drawableview.

Odaym avatar Odaym commented on July 17, 2024

Hi Chris, today I just pulled 0.6.0 and it worked fine and included both fixes that were in limit_canvas_size, I don't have to import that branch as a library anymore. Just wanna thank you 👍

from drawableview.

PaNaVTEC avatar PaNaVTEC commented on July 17, 2024

thanks to you for using it :)

from drawableview.

imsocb avatar imsocb commented on July 17, 2024

Hi Chris, Sorry for bringing up the topic again. I'm having similar issue saving the background image with the drawn paint together onto the same bitmap. Hope you can offer me some advice on that. Thanks

 @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        if(resultCode == RESULT_OK){
            if(requestCode == CAMERA_REQUEST){
                                OriginalBitmap = getRotatedBitmap(bitmap,90);

                                drawableView.setBackground(new BitmapDrawable(getResources(), OriginalBitmap));
                                config.setStrokeColor(Color.BLUE);
                                config.setShowCanvasBounds(true); 
                                config.setStrokeWidth(50.0f);
                                config.setCanvasHeight(height);
                                config.setCanvasWidth(width);
                                drawableView.setConfig(config);
}
}
}

ivSavesetOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                try {

                    OriginalBitmap = ImageLoader.init().from(selectedPhoto).requestSize(512,512).getBitmap();

                    try {
                        OriginalBitmap = drawableView.obtainBitmap(OriginalBitmap);  
// Tried OriginalBitmap = drawableView.obtainBitmap(); however, on the server it store only the drawn bitmap and internal memory only the background image.
                        storeImage(OriginalBitmap);
                    }
                    catch (IOException e) {
e.printStackTrace();  
                    }
}
String encodedImage = ImageBase64.encode(OriginalBitmap);

from drawableview.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.