I have drawn a uiimage on a cgcontext
CGContextDrawImage(tempContext, CGRectMake(0,0,myRect.size.width,myRect.size.height), imgRef);
but once user is done with the current image, i want to clear the tempContext so that I can rescale / manipulate the image and redraw it on the same context.
for this i want to clear the the context and make it clean.
I tried CgContextClearRect but it didn't worked :(
try this one, it works for me: CGContextClearRect(UIGraphicsGetCurrentContext(), rect);
Related
I am wondering how I would be able to use animated shapes inside a movieclip that would be acting as a mask?
In my Animate CC canvas file I have an instance (stripeMask) that should mask the below instance called mapAnim.
stripeMask contains shapes that are animating in.
So when the function maskIn is called, the playhead should move to the first frame inside the stripeMask clip (the one after frame 0) and animate the mask like so:
function maskIn(){
//maskAnimation to reveal image below
stripeMask.gotoAndPlay(1);
}
I love AnimateCC and it works great, but the need for creating more complex and animated masks is there and it's not easy to achieve unless I am missing something here.
Thanks!
Currently you can only use a Shape as a mask, not a Container or MovieClip.
If you want to do something more complex, you can use something like AlphaMaskFilter, but it has to be cached, and then updated every time the mask OR the content updates:
something.filters = [new createjs.AlphaMaskFilter(stripeMask)];
something cache(0,0,w,h);
// On Change
something.updateCache(); // Re-caches
The source of the AlphaMaskFilter must be an image, so you can either point to a Bitmap image, or a cacheCanvas of a mask clip you have also cached. Note that if the mask changes, the cache has to be updated as well.
This is admittedly not a fantastic solution, and we are working on other options.
I have a IKImageView and a NSImageView as a subview. Subviews are supposed to get drawn above their master view. I tried an NSImageView with the same subview, and it worked fine, but I really need to be able to move the image around with the mouse, and zoom it with a slider, and I think IKImageView is a bit easier.
What happens is this:
As you can see, the small picture (subview) is below the image on the IKImageView, but in front of the background of IKImageView.
How can I fix this?
ps: Do you think I should use NSImageView? If so, how would I move it around, and zoom?
call addSubview again everytime after I set the IKImageView's image.
That work for me.
I'm pulling images from the camera roll to display in my app, and portrait taken pictures work just fine, but landscape images get all funky smushed together.
UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];
displayPhoto.image = image;
I've figured out how to check the length and width of the pictures themselves, and therefore can do an if else statement to only rotate landscape pictures... but trying to find working code to actually rotate the images is difficult. I found an answer here, but he's calling functions that don't exist, and clearly the code did not work for me :p. Any assistance would be greatly appreciated. Thanks.
u have to use
[displayPhoto setContentMode:UIViewContentModeScaleAspectFit];
Draw a circle,make a rounded UIImageView in it.How to get this, please guide me.
thx!
Let's put it this way,
First we create a UIImageView to the size of the circle you want.Let's say you want this image to be a circular image,
http://united4iran.org/wp-content/uploads/2010/11/cell-phone-in-canada.jpg
Then you create another UIImageView one top of the previous one to the size of 320x480 and set this image to it (Assume this image size is 320x480),
Note: also remember that inner area of the circle in above image is transparent.
Then you should get a image like this,
http://img580.imageshack.us/img580/782/testjkn.png
Hope this will help you.
I have an application that is set in landscape mode because of the content it contains. One of the things I want to do is take a picture of a piece of paper. I present the UIImagePickerController locked in portrait mode because it fits the paper size. After the user takes the picture I load that image as a background on a UIWebView. The reason I use a webview is because sometimes I need to load a .pdf there as well. Anyway, I'm setting the background using CSS. Here is the code...
//img is the path to an image.
myHtml = [NSString stringWithFormat:
#"<html><head>"
"</head>"
"<body><img src='%#'></body></html>", img];
[resume loadHTMLString:myHtml baseURL:baseURL];
The problem is, the image is displayed in landscape when the app returns to the UIWebView. Everything else is normal as far as text etc. Is there some reason that images are rotated 90 degrees to fit properly or something? I have tried pretty much everything with no luck.
The other thing is that we I retake a picture and reload the webView the old image remains.
You need to change the orientation of the image from its exif header if there is orientation info available in it. Identifying the picture orientation is the hard part, rotation of imgs can be done easily using css -webkit-transform: rotate(-90deg);
It does have to do with the exif data. While using a webkit transform may be ok for use in just the web view once, if you want to use the image later and have it always be the right orientation I'd use the categories given here:
http://vocaro.com/trevor/blog/2009/10/12/resize-a-uiimage-the-right-way/
The article does a great job explaining exactly why the rotation occurs and the code does a nice job of 'fixing' the 'problem' so that you can then make use of the image without having to do extra things or worry about whether it'll be displayed correctly (even though the UIImageView takes the orientation into account).
You can resize with this to the same size it originally was, and it should fix the orientation issue.