/* * (non-Javadoc) * * @see com.aviary.android.feather.effects.AbstractEffectPanel#onGenerateResult() */ @Override protected void onGenerateResult() { MemeFilter filter = (MemeFilter) FilterLoaderFactory.get(Filters.MEME); flattenText(topHv, filter); flattenText(bottomHv, filter); MoaActionList actionList = (MoaActionList) filter.getActions().clone(); super.onGenerateResult(actionList); }
/** * Flatten text. * * @param hv the hv */ private void flattenText(final DrawableHighlightView hv, final MemeFilter filter) { if (hv != null) { hv.setHidden(true); final Matrix mImageMatrix = mImageView.getImageViewMatrix(); float[] matrixValues = getMatrixValues(mImageMatrix); mLogger.log("image scaled: " + matrixValues[Matrix.MSCALE_X]); // TODO: check this modification final int width = (int) (mBitmap.getWidth()); final int height = (int) (mBitmap.getHeight()); final RectF cropRect = hv.getCropRectF(); final Rect rect = new Rect( (int) cropRect.left, (int) cropRect.top, (int) cropRect.right, (int) cropRect.bottom); final MemeTextDrawable editable = (MemeTextDrawable) hv.getContent(); final int saveCount = mCanvas.save(Canvas.MATRIX_SAVE_FLAG); // force end edit and hide the blinking cursor editable.endEdit(); editable.invalidateSelf(); editable.setContentSize(width, height); editable.setBounds(rect.left, rect.top, rect.right, rect.bottom); editable.draw(mCanvas); if (topHv == hv) { filter.setTopText( (String) editable.getText(), (double) editable.getTextSize() / mBitmap.getWidth()); filter.setTopOffset( (cropRect.left + (double) editable.getXoff()) / mBitmap.getWidth(), (cropRect.top + (double) editable.getYoff()) / mBitmap.getHeight()); // action.setValue( "toptext", (String) editable.getText() ); // action.setValue( "topsize", (double)editable.getTextSize()/mBitmap.getWidth() ); // action.setValue( "topxoff", (cropRect.left + // (double)editable.getXoff())/mBitmap.getWidth() ); // action.setValue( "topyoff", (cropRect.top + // (double)editable.getYoff())/mBitmap.getHeight() ); } else { filter.setBottomText( (String) editable.getText(), (double) editable.getTextSize() / mBitmap.getWidth()); filter.setBottomOffset( (cropRect.left + (double) editable.getXoff()) / mBitmap.getWidth(), (cropRect.top + (double) editable.getYoff()) / mBitmap.getHeight()); // action.setValue( "bottomtext", (String) editable.getText() ); // action.setValue( "bottomsize", (double)editable.getTextSize()/mBitmap.getWidth() ); // action.setValue( "bottomxoff", (cropRect.left + // (double)editable.getXoff())/mBitmap.getWidth() ); // action.setValue( "bottomyoff", (cropRect.top + // (double)editable.getYoff())/mBitmap.getHeight() ); } filter.setTextScale(matrixValues[Matrix.MSCALE_X]); // action.setValue( "scale", matrixValues[Matrix.MSCALE_X] ); // action.setValue( "textsize", editable.getTextSize() ); mCanvas.restoreToCount(saveCount); mImageView.invalidate(); } onPreviewChanged(mPreview, false); }