ACEDrawingView icon indicating copy to clipboard operation
ACEDrawingView copied to clipboard

how to add the background image ?

Open ghost opened this issue 11 years ago • 10 comments

thanks.

ghost avatar Jan 20 '13 14:01 ghost

This is a transparent view. You can add it on the top of an imageview with your background image

acerbetti avatar Jan 20 '13 15:01 acerbetti

but i can't export to an UIImage with the background image or background color...

ghost avatar Jan 20 '13 16:01 ghost

when i add the UIImageView to the ACEDrawingView, then i can't draw anything on the UIImageView .

ghost avatar Jan 20 '13 17:01 ghost

ah, ok. So you have to blend the images.. For example

- (UIImage *)blendImage
{    
    UIImage *bottomImage = <your image>
    UIImage *image = self.drawView.image;

    UIGraphicsBeginImageContext( bottomImage.size );
    CGRect imageFrame = CGRectMake(0.0f, 0.0f, bottomImage.size.width, bottomImage.size.height);

    // Use existing opacity as is
    [bottomImage drawInRect:imageFrame];

    // Apply supplied opacity
    [image drawInRect:imageFrame blendMode:kCGBlendModeNormal alpha:0.8];

    UIImage *blendImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();

    return blendImage;
}

acerbetti avatar Jan 20 '13 17:01 acerbetti

thank u very mush...

ghost avatar Jan 21 '13 01:01 ghost

@acerbetti When I use the method above, it works perfectly. However, if I then draw on the image, and hit the 'Undo' button, the blendImage is cleared from the view. Is there a way to prevent this?

In other words, if the view counts the number of "drawn points" to manage the undo sequence, is there a way to reset the undo counter to zero (so that blending the images cannot be undone)? I'm trying to do basically the same thing with my method here: https://github.com/acerbetti/ACEDrawingView/issues/2#issuecomment-30702919, which also keeps the @2x image nice and sharp.

adamdehaven avatar Dec 17 '13 13:12 adamdehaven

I want to use eraser to erase with background image how to use eraser to erase blendImage?

sonysm avatar May 04 '15 04:05 sonysm

This sample is not good

superpic avatar Jun 12 '15 09:06 superpic

I have made some changes for drawing on image. Please have a look here

deviserRahul avatar Oct 08 '16 04:10 deviserRahul

Can you tell me how I can mask the canvas with an image with transparent areas?

I only want to be able to paint in the non transparent areas?

Or vice versa.

Many thanks.

mediaRare avatar Apr 24 '20 03:04 mediaRare