I'm getting at one point with iOS. I have 2 UIImage which are bgImg & img. BgImg is actually the background image, img is a smaller one which places in the bgImg' bounds.
I need to combine 2 of these images as one, called finalImg. The problem is img should be rotated in a select angle. I have done so many tests with no result. If you have any ideas, please help me. What I need is just to return the combined image.
Thanks so much, my fellow iOS developers.
Thang
You need to create a graphics context, draw your two images to it, and then capture a new image from the context, as described in this post:
Saving 2 UIImages to one while saving rotation, resize info and its quality
If you don't already have the rotation of your foreground image worked out, then the first answer to that post should help you as well.
Related
For my website, I want to use the vector image as shown here: http://www.sketchappsources.com/free-source/226-iphone-5.html
It's an iPhone 5 that is tilted.
Now I need to add my image to the screen which means I need to 3D-tilt it. I've tried and searched a lot but couldn't figure out how to transform my image so that it fits the iPhone 5 screen.
Any help in guiding me how to 3D transform my image would be greatly appreciated!
Cheers,
Frank
I recently released a plugin solving the exact issue, it allows you to draw a shape with the Vector tool and then apply the content of an artboard into the area. It's called Magic Mirror, please take a look at http://magicmirror.design
I've been stuck at this for quite some time. I've looked at many other answers and also at Apple's examples.
What I want to know is how I can go about loading large images in UIScrollView, and be able to page through them and zoom in to them, like the Photos app.
I'm working on an app where I need to scroll through large images (by large, I mean images greater than 1024 x 1024). I've already implemented something similar to what the photos app does. However, now that I'm using large images, I get memory warnings and stuff. I know why I'm getting the warning, and I know that I need to Tile the images.
Apple's examples demonstrate tiling with small images which are already present. My app will be downloading multiple images, saving them on a disk and the user will be able to look at them at a later time. Thus, I cannot have the images cut up using other programs.
I need something wherein I can tile the full size images. Any help will be greatly appreciated. Additionally, as I mentioned earlier, I know that I have to do something with Tiling. However, I'm new to this, and I would greatly appreciate if the answers contain some sample code, which I can use as a start off point.
I've looked at other questions, and none seemed to have been answered to my satisfaction, owing to which, I'm asking this question again.
Thanks again!
To work with tiling you'll need to use a CaTiledLayer in your view. Googling for it will give you good information. Basically you declare that the UIVIew is using it, declare some levels of details for zooming and in the drawRect you'll receive each tile as the rect parameter.
To tile the image, load in a UIImage (it uses memory, but quite less than showing it) and use for each tile you want something like:
UIGraphicsBeginImageContextWithOptions(tileSize, YES, 1);
CGContextRef ctx = UIGraphicsGetCurrentContext();
CGContextTranslateCTM(ctx, -tileSize.width * columnNumber, -tileSize.height*rowNumber);
[img drawInRect:CGRectMake(0, 0, tileSize.width, tileSize.height)];
UIImage* imgCut = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
and save imgCut. You probably will want to generate tiling with different zooms if you use different level of detail in your CATiledLayer.
I'm new to iPhone graphics and it's a bit daunting.
The problem: I have UIImageA, and UIImageB. Both are the same picture, except UIImageB has all the pixels values darkened.
I'd like to copy an arbitrary piece of UIImageA onto the top of UIImageB. The end result would be a dark image, with the part of the original image bright.
My guess is that I will need to:
Create a "path" that is the arbitrary shape to copy. I think I can figure this out.
Take UIImageA and somehow crop it or mask it to the path.
Copy the part of UIImageA onto UIImageB at the exact same position.
It's steps 2 and 3 that have me confused. I've seen many examples of cropping images to a rectangle, or masking images with another pre-defined image, but nothing that exactly does this.
Does anyone have any general pointers?
You could try Core Image.
You can do all that with CGImage in your environment. You can
use a bitmap or layer context and then later render it on whatever view
you wish.
There is a good Core Graphics Quartz tutorial at
http://developer.apple.com/library/mac/#documentation/GraphicsImaging/Conceptual/drawingwithquartz2d/Introduction/Introduction.html
I have an array of jpgs (7) that I would like to print. All the images are the same size, 900x1382, and I would like to print them two to a page by rotating them 90 degrees and printing them top/bottom on a letter sized piece of paper.
It sounds like I need to create a printFormatter but that's where I am getting stuck. I have read through Apple's Drawing and Printing Guide probably 10 times and I cannot figure how to do what I want to do.
Can someone help me out or at least point me in the direction of a good tutorial?
- (void)drawPageAtIndex:(NSInteger)pageIndex inRect:(CGRect)printableRect
{
// You can draw images in the specified rect.
}
Try to subclass UIPageRenderer, then override the above function. You can draw the images in specified rect. I think you have to check the Apple's PrintPhoto sample code, and custom drawing from your old guide. Check it and add comments about this. thanks :)
I'm trying to work out how to draw from a TexturePage using CoreGraphics.
Given a texture page (CGImageRef) which contains multiple 64x64 packed textures, how do I render sub areas from that page onto the device context.
CGContextDrawImage seems to only take a destination rect. I noticed CGImageCreateWithImageInRect, however this creates a new image. I don't want a new image I simply want to draw from the original image.
I'm sure this is possible, however I'm new to iPhone development.
Any help much appreciated.
Thanks
What's wrong with CGImageCreateWithImageInRect?
CGImageRef subImage = CGImageCreateWithImageInRect(image, srcRect);
if (subImage) {
CGContextDrawImage(context, destRect, subImage);
CFRelease(subImage);
}
Edit: Wait a minute. Use CGImageCreateWithImageInRect. That is what it's for.
Here are the ideas I wrote up initially; I will leave them in case they're useful.
See if you can create a sub-image of some kind from another image, such that it borrows the original image's buffer (much like some substring implementations). Then you could draw using the sub-image.
It might be that Core Graphics is intended more for compositing than for image manipulation, so you may have to use separate image files in your application bundle. If the SDK docs don't particularly recommend what you're doing, then I suggest you go that route since it seems the most simple and natural way to do it.
You could use OpenGLES instead, in which case you can specify the texture coordinates of polygon vertices to select just that section of your big texture.