Android-RTEditor icon indicating copy to clipboard operation
Android-RTEditor copied to clipboard

Insert very large image

Open borjaMorilla opened this issue 8 years ago • 18 comments

Hi!! I have a problem when I insert a image very large, (1800x1800 for example), because the image is very large then i cant to see good the image in the editor, the image output from the edges, how can resize this image when it is inserting in the editor?

I've only been able to can resize the image when i save it in a folder of my app using my custom RTMedia, but I would like to save the same height and width but when it is displayed in the editor has a size adapted to the screen.

Thanks for this library ^^

borjaMorilla avatar Nov 10 '16 16:11 borjaMorilla

If you extended RTMedia then you can override the getWidth and getHeight methods to get the real width and height and divede them by 8 or something. Maybe it will do the job. But keep in mind that all images stored in this custom RTMedia will be display smaller.

long1eu avatar Nov 10 '16 16:11 long1eu

I will try to do it, thanks for answer me fast :D

borjaMorilla avatar Nov 10 '16 16:11 borjaMorilla

:D

long1eu avatar Nov 10 '16 16:11 long1eu

I'm trying to do it but i dont know what class would extends of RTMedia =/

I have done this with my custom RTMediaFactory....

public class RTMediaCustom extends RTMediaFactoryImpl implements RTMedia{

....


    @Override
     public RTImage createImage(RTMediaSource mediaSource) {
     ..........
     }

    @Override
    public int getWidth(){
        WindowManager wm = (WindowManager) ApplicationContext.getAppContext().getSystemService(Context.WINDOW_SERVICE);
        Display display = wm.getDefaultDisplay();
        Point size = new Point();
        display.getSize(size);
        return (int)(size.x*0.9);
    }

    @Override
    public int getHeight() {
        WindowManager wm = (WindowManager) ApplicationContext.getAppContext().getSystemService(Context.WINDOW_SERVICE);
        Display display = wm.getDefaultDisplay();
        Point size = new Point();
        display.getSize(size);
        return (int)(size.y*0.9);
    }

}


But when i debug my app and I go in the RTEditor, overwritten (getWidth() and getHeight()) methods do not start =/

borjaMorilla avatar Nov 10 '16 17:11 borjaMorilla

you need to extend RTMediaImpl

long1eu avatar Nov 10 '16 17:11 long1eu

You need to extend RTMediaFactoryImpl and RTImageImpl, e.g: RTMediaCustom extends RTMediaFactoryImpl and RTImageCustom extends RTImageImpl.

Your custom RTMediaFactoryImpl overrides createImage to return your custom RTImageImpl. Don't try to do it in one class since there's no multiple inheritance in Java and it also doesn't make sense from a design perspective.

1gravity avatar Nov 10 '16 17:11 1gravity

nice to see you again :D

long1eu avatar Nov 10 '16 17:11 long1eu

I was trying this... but this doesn't work because methods getWith() and getHeigth() don't start at any moments. But methods are good because when im debuging if I try to use its, they return good dates.

Where are using this methods ? Are these methods used in some class?

borjaMorilla avatar Nov 11 '16 09:11 borjaMorilla

did you tried the suggestion of @1gravity ? Did you implement both the classes?

long1eu avatar Nov 11 '16 10:11 long1eu

Yes, I implemented both classes =7

borjaMorilla avatar Nov 11 '16 10:11 borjaMorilla

You can look it

public class RTMediaFactoryCustom extends RTMediaFactoryImpl {

    private File mStoragePath;

    public RTMediaFactoryCustom(Context context) {
        super(context);
    }

    public RTMediaFactoryCustom(Context context, boolean externalStorage) {
        super(context,externalStorage);
       mStoragePath = externalStorage ?
                context.getExternalFilesDir(null) :
                context.getFilesDir();
    }

    @Override
    public RTImage createImage(RTMediaSource mediaSource) {
        File targetFile = loadMedia(mediaSource);
        if(targetFile==null){
            return null;
        }else{
            RTImageCustom rtImageCustom= new RTImageCustom(targetFile.getAbsolutePath());
            return rtImageCustom;
        }
    }
}
public class RTImageCustom extends RTMediaImpl implements RTImage {
    public RTImageCustom(String filePath) {
        super(filePath);
    }

    @Override
    public int getWidth(){
        WindowManager wm = (WindowManager) ApplicationContext.getAppContext().getSystemService(Context.WINDOW_SERVICE);
        Display display = wm.getDefaultDisplay();
        Point size = new Point();
        display.getSize(size);
        /*return (int)(size.x*0.9);*/
        return 100;
    }

    @Override
    public int getHeight() {
        WindowManager wm = (WindowManager) ApplicationContext.getAppContext().getSystemService(Context.WINDOW_SERVICE);
        Display display = wm.getDefaultDisplay();
        Point size = new Point();
        display.getSize(size);
        return 100;
    }
}

borjaMorilla avatar Nov 11 '16 11:11 borjaMorilla

public class RTImageCustom extends RTImageImpl {

long1eu avatar Nov 11 '16 11:11 long1eu

try this

long1eu avatar Nov 11 '16 11:11 long1eu

and now you have to change this on ImageProcessor

long1eu avatar Nov 11 '16 11:11 long1eu

do you have teamviewer?

long1eu avatar Nov 11 '16 11:11 long1eu

I'm using the library in my app I can't overriding this class (ImageProcessor) =/ and I can't install TeamViewer in this PC sorry

borjaMorilla avatar Nov 11 '16 11:11 borjaMorilla

I'm sorry too, is to long to explain. You need to figure it out by yourself unless @1gravity helps you. Have a good day.

long1eu avatar Nov 11 '16 11:11 long1eu

Thanks ^^

borjaMorilla avatar Nov 11 '16 12:11 borjaMorilla