Java Code Examples for org.telegram.messenger.SharedConfig#getLastLocalId()

The following examples show how to use org.telegram.messenger.SharedConfig#getLastLocalId() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CropView.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
public Bitmap getResult(MediaController.MediaEditState editState) {
    if (state == null || !state.hasChanges() && state.getBaseRotation() < EPSILON && freeform) {
        return bitmap;
    }

    RectF cropRect = new RectF();
    areaView.getCropRect(cropRect);
    RectF sizeRect = new RectF(0, 0, RESULT_SIDE, RESULT_SIDE);

    float w = scaleWidthToMaxSize(cropRect, sizeRect);
    int width = (int) Math.ceil(w);
    int height = (int) (Math.ceil(width / areaView.getAspectRatio()));
    float scale = width / areaView.getCropWidth();

    Bitmap resultBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);

    Matrix matrix = new Matrix();
    matrix.postTranslate(-state.getWidth() / 2, -state.getHeight() / 2);
    matrix.postRotate(state.getOrientation());
    state.getConcatMatrix(matrix);
    matrix.postScale(scale, scale);
    matrix.postTranslate(width / 2, height / 2);

    Canvas canvas = new Canvas(resultBitmap);

    if (editState.paintPath != null) {
        editBitmap(editState.paintPath, null, canvas, resultBitmap, Bitmap.CompressFormat.PNG, scale, null, false);
        if (!editState.paintPath.equals(editState.fullPaintPath)) {
            editBitmap(editState.fullPaintPath, null, canvas, resultBitmap, Bitmap.CompressFormat.PNG, scale, editState.mediaEntities, true);
        }
    }
    if (editState.filterPath != null) {
        if (editState.croppedPath == null) {
            File f = new File(FileLoader.getDirectory(FileLoader.MEDIA_DIR_CACHE), SharedConfig.getLastLocalId() + "_temp.jpg");
            editState.croppedPath = f.getAbsolutePath();
        }
        Bitmap b = ImageLoader.loadBitmap(editState.getPath(), null, bitmap.getWidth(), bitmap.getHeight(), true);
        editBitmap(editState.croppedPath, b, canvas, resultBitmap, Bitmap.CompressFormat.JPEG, scale, null, false);
    }

    canvas.drawBitmap(bitmap, matrix, new Paint(FILTER_BITMAP_FLAG));
    return resultBitmap;
}
 
Example 2
Source File: CropView.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
public Bitmap getResult(MediaController.MediaEditState editState) {
    if (state == null || !state.hasChanges() && state.getBaseRotation() < EPSILON && freeform) {
        return bitmap;
    }

    RectF cropRect = new RectF();
    areaView.getCropRect(cropRect);
    RectF sizeRect = new RectF(0, 0, RESULT_SIDE, RESULT_SIDE);

    float w = scaleWidthToMaxSize(cropRect, sizeRect);
    int width = (int) Math.ceil(w);
    int height = (int) (Math.ceil(width / areaView.getAspectRatio()));
    float scale = width / areaView.getCropWidth();

    Bitmap resultBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);

    Matrix matrix = new Matrix();
    matrix.postTranslate(-state.getWidth() / 2, -state.getHeight() / 2);
    matrix.postRotate(state.getOrientation());
    state.getConcatMatrix(matrix);
    matrix.postScale(scale, scale);
    matrix.postTranslate(width / 2, height / 2);

    Canvas canvas = new Canvas(resultBitmap);

    if (editState.paintPath != null) {
        editBitmap(editState.paintPath, null, canvas, resultBitmap, Bitmap.CompressFormat.PNG, scale, null, false);
        if (!editState.paintPath.equals(editState.fullPaintPath)) {
            editBitmap(editState.fullPaintPath, null, canvas, resultBitmap, Bitmap.CompressFormat.PNG, scale, editState.mediaEntities, true);
        }
    }
    if (editState.filterPath != null) {
        if (editState.croppedPath == null) {
            File f = new File(FileLoader.getDirectory(FileLoader.MEDIA_DIR_CACHE), SharedConfig.getLastLocalId() + "_temp.jpg");
            editState.croppedPath = f.getAbsolutePath();
        }
        Bitmap b = ImageLoader.loadBitmap(editState.getPath(), null, bitmap.getWidth(), bitmap.getHeight(), true);
        editBitmap(editState.croppedPath, b, canvas, resultBitmap, Bitmap.CompressFormat.JPEG, scale, null, false);
    }

    canvas.drawBitmap(bitmap, matrix, new Paint(FILTER_BITMAP_FLAG));
    return resultBitmap;
}