issue on image drawing in pdf page- objective c - ios

I am working on pdf creation right now, everything works fine except image drawing, it draws image's upper left corner only; with extra zoomed. But it works on simulator,code shows below;
UIImage *plotImage=[[UIImage alloc]initWithContentsOfFile:
[localPictureArray objectAtIndex:i]];
[plotImage drawInRect:CGRectMake
(kMargin, currentPageY, plotImage.size.width, plotImage.size.height)];
since iam a starter i need your valuable help. thanks in advance.

The problem is likely your CGRect. Assuming that your x and y margins are OK, you probably have an image that is too large to fit on the page as measured from these margins.
You need to determine how far you can draw to the right and bottom and scale the image accordingly. (e.g. as described here)

Related

iOS 'colorWithPatternImage' is adding 1 px borders around my images?

I'm using UIColor's colorWithPatternImage function to set a tiled image on one of my views. The result is a grid of 1 pixel lines all over.
Fig: The clear color grid of lines is the issue.
My intention was to obtain a perfect background using the tiled image.
I first suspected that the image I was using could be faulty, but zooming it to 800% doesn't really show the presence of any transparent one-pixel border anywhere.
Here's the image (#2x version):
Any ideas what it could be related to?
Thanks,
p.
you are doing everything fine, but your problem is that your pattern image have 1 pixel line on the top an 1 pixel line on the left side with alpha color so you only need to modify your pattern image simply as that, I have been testing and this is the problem
I hope this helps you

UIImageView - anyway to use 2 content modes at the same time?

So in my scenario, I have a square that is (for understanding's sake) 100x100 and need to display an image that is 300x800 inside of it.
What I want to do is be able to have the image scale just as it would with UIViewContentMode.ScaleAspectFill so that the width scales properly to 100.
However, after that, I would like to then "move" the image up to the top of the image instead of it putting it inside the imageView right in the center, basically what UIViewContentMode.Top does. However that doesn't scale it first.
Is there anyway to do this type of behavior with the built in tools? Anyway to add multiple contentModes?
I already had a helper function that I wrote that scaled an image to a specific size passed in, so I just wrote a function that calculated the scaled image that would fit into the smaller square I had similar to the size AspectFill would do, and then I wrote code that would crop it with the rectangle size I needed at (0,0).

Constrain image Movement in Specific Area in Window RT App

Ok.
To describe what I want to do, have you ever used Telerik Crop function Image Editor control?
I want exactly same functionality.
I want to use that control but, I am working on Universal app that has no control like Image Editor from telerik.
That control does are
1. There is a fixed rect or canvas for cropping image.
2. If the original image is in the area of canvas(or Rect) image's opacity = 1(i guess) and if the original image is out of canvas area, image looks dim(maybe opacity 0.5 or some)
3. Constrain original image movement in the canvas.
I will implement this function in Image.ManipulationDelta event.
Do I have to get each point value of canvas? or can I do it by using Width or Height of Canvas?
How Do I do that?
Can anyone help me?
any hint?
I'm not familiar with that particular control, but I think I understand what you want.
To constrain the movement of an Image within a Canvas you can check where the Image will end up in your ManipulationDelta and limit any translation, scaling, and rotation appropriately. If the bounding box of the Image after the transform applies is within the Canvas then apply the transform. Otherwise roll it back and do nothing. I have sample code for this in my blog entry: Constraining manipulations
To dim the area outside of the crop I'd create a shape and fill it with a partially transparent brush. The all-in-one code framework sample How to crop bitmap in a Windows Store app demonstrates this technique. I believe the sample targets Windows Store 8.0 apps, but essentially the same code should work on Windows Store 8.1 or Windows Phone Store 8.1 apps.

Xcode 5 Image Slicing

I'm trying to slice an image in assets Xcode 5. I don't know if what I'm trying to do is possible with slicing.
The image looks like this:
I need to change the width and the height of the image, although not at the same time. The closest I've got is when I use Horizontal for the height and Vertical for the width. The problem is when I change the width, the left side of the image starts as a straight line and the skews and change to the original shape.
I'm about to give up on the idea of slicing and just create three images, left, center and right. Is that the only way to go?
This is how my current slice looks like:
Is there any way to change it so it works at least for the width?
UPDATE
Instead of slicing the image I used a mask and moved the mask.
Slicing works by taking the center section, and stretching it to fill the required space and then putting on the image end caps.
Because your button has a continuous diagonal line you will not be able to slice it. It will stretch the image out like so:
In fact even if you make a centre section and end caps you will still have the same issue as this image can only be scaled.
If you only need a finite set of heights then you should create individual assets for each height that can be sliced horizontally. If you need N heights then you should look into using core graphics to draw your shape in code in a -drawRect: method for arbitrary dimensions.
P.S. if you want to horizontally slice so you can grow the width its most optimal to have only 1 pixel width of image that will be stretched out so your button image resources would look a bit like this:
Aha. TIL: You can change the slicing options from the attributes inspector in the right hand pane in Xcode. To make your slicing work choose only "Horizontal"

Stretchable UIImage chat bubbles

I have the following image attached that I use as the background of each of my chat messages (i.e. bubbles). What values should I use for X and Y in UIImage stretchableImageWithLeftCapWidth: X topCapHeight: Y]; to insure that the pointy end of the image stays in the middle at all times.
I tried using X=20 Y=5 but the pointy end goes to the bottom.
You can't do that with a single stretchable image. A stretchable image always has just one rectangular area that is stretched. To get the appearance you want however, you'd need to stretch two parts – the areas above and below the pointer.
You need to use at least two images. The easiest would probably be to make the pointer a separate image and center it manually on top of the rounded rectangle.
You can't do that and keep the arrow in the center -- well, not in iOS 6 and earlier ;-)
This is why the little speech arrow in Messages.app is at the bottom corner of the speech bubbles. They stretch an area of pixels that is just above that region.
So, you could make things easier for yourself by following Messages.app's lead and design around the limitation.

Resources