Adding two images and make one [closed] - ios

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I am new programming IOS app , and I got into this problem : I have two images in the app that I want to post in twitter , but Twitter just accept one picture to be uploaded , so I came out with the idea to make Image A + Image B just One Image. I already have the posting and resizing the images process done. However, I need help to make Image A + Image B just one Image. Anyone can HELP? Thank you.

Here is some code you can use...
Assumptions:
You have your two images already initialized
The two images have the same dimension. If your images have different sizes you'll have to play around with the dimensions yourself.
UIImage *girl1 = INITIALIZE_HERE;
UIImage *girl2 = INITIALIZE_HERE;
// Get the size of your images (assumed to be the same)
CGSize size = [girl1 size];
// Create a graphic context that you can draw to. You can change the size of the
// graphics context (your 'canvas') by modifying the parameters inside the
// CGSizeMake function.
UIGraphicsBeginImageContextWithOptions(CGSizeMake(size.width*2, size.height), NO, 0);
// Draw the first image to your newly created graphic context
[girl1 drawAtPoint:CGPointMake(0,0)];
// Draw your second image to your graphic context
[girl2 drawAtPoint:CGPointMake(size.width,0)];
// Get the new image from the graphic context
UIImage *theOneImage = UIGraphicsGetImageFromCurrentImageContext();
// Get rid of the graphic context
UIGraphicsEndImageContext();
Hope this helps!

Related

get subImage from image [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I have following image,
from that I need to use separate images like below.
I don't know which kind of functionalities can be work here.
I don't want to just crop that image from photoshop or anything like that. I know there is some way to achieve this. But don't know how to get sub-image.
I've searched somewhere long ago but now can't find the way.
could you please help me to get this.
I've already visited here.
Swift 4
If I understood correctly you would want something like this:
[YOUR_FIRST_IMAGE]
let image = UIImage(named: "[YOUR_FIRST_IMAGE]")
let fromRect = CGRect(x:[OFFSET_HERE], y:0,width:[WIDTH_OF_EACH_ICON],height:[HEIGHT_OF_EACH_ICON])
let croppedImageFromRect = image?.cgImage!.cropping(to: fromRect)
let dottedCircleGreenImage = UIImage(cgImage: croppedImageFromRect!)
imageView.image = dottedCircleGreenImage
To select a different sub image from this collection ([YOUR_FIRST_IMAGE]) you have to offset the x (in the CGRect) with the width of each icon multiplied by the position of image you want minus 1.
For example to select the fifth one: . Get the width of a single icon than multiply it by 5.
Notes:
imageView in the above example is some outlet or form of reference to a UIImageView in a view.
force unwrapping variables is not a good practise, this is just per example.

is it possible to make custom shaped buttons in iOS [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
Or some kind of UI objects that can
interact with users
be drawn into any shape, for example, oval.
yes. It is pretty simple.
UIImage *buttonImage = [UIImage imageNamed:#"greenButton.png"];
UIImage *buttonImageHighlight = [UIImage imageNamed:#"greenButtonHighlight.png"];
[myCustomButton setBackgroundImage:buttonImage forState:UIControlStateNormal];
[myCustomButton setBackgroundImage:buttonImageHighlight forState:UIControlStateHighlighted];
It is possible to do it in a variety of ways. Rydgaze gave you the option for using a UIImage as your custom button. If you are looking for a code only way then I would suggest UIBezierPath. UIBezierPath allow's you to draw any shape that you want as well as customize the look. With UIBezierPath I could draw a star and fill it with anything that I would like.
Here is the link to the Reference: https://developer.apple.com/library/ios/documentation/uikit/reference/UIBezierPath_class/Reference/Reference.html
The idea is that you create a view class. In that view's drawRect method you will design whatever shape you are looking to create and customize it to what you see fit. For you button you would set its self.view to be the view that of your custom UIBezierPath class. That will just draw your custom shape as the button.
The advantage's to writing your button's in code are that it will for one be faster. It also takes up significantly less size because it isn't storing an image file. Also you are able to continue the customization of your shape. That mean's you could change the color, dimensions, etc. very easily.

Detect end of image [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I have a bunch of UIImages that consist of black and white book pages. I want to be able to "crop" or "cut" the image based on where the page ends (Where the white space begins). To illustrate what I mean, look at the image below. I want to crop the image programatically right after the word "Sie".
I am not sure how to go about this problem. I have gave it some thought however, perhaps detecting where the black pixels stop since it will always be black and white but not sure how to properly do this. Can anyone offer any insight or tell me how this may be done?
Thank you so much!
Here's some python code I wrote using the Python Imaging Library. It finds the lowest black pixel, and then crops the image five pixels down from that y value.
import Image
img = Image.open("yourimage.fileformat")
width,_ = img.size
lowestblacky = 0
for i, px in enumerate(img.getdata()):
if px[:3] == (0, 0, 0):
y = i/width
if y > lowestblacky:
lowestblacky = y
img.crop((0,0,width,lowestblacky+5)).save("yourimagecropped.fileformat")
Python is available on nearly all operating systems, so I hope you'll be able to use this. If you want to crop the image right after the last black pixel, simply remove the "+5" from the last line, or change the value to your liking.
Convert the image into pixel values. Start with the bottom line of pixels and look for black pixels. If some are found, the line is the end of the image. If there is no black pixel, continue to the next line of pixels.
Actually, "black" pixel is probably too simplified. A good solution would use a limit of gray (every image has some noise) or even better, a change in pixel contrast. You can also apply an image filter (e.g. Edge detection or sharpen) before starting the detection algorithm.

How to detect if an image is square? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Improve this question
I am making a desktop image editing software using Processing. It will allow the user to select the image to edit. The area in which the user can do the editing is a fixed 640 x 480 screen.
This means that I will have to scale the input image to fit the screen. That is easy to do with rectangular images. The problem arises when dealing with square images.
Programatically, 2500x2501 is not a square image. For all practical purposes it is.
How do I make sure that I properly scale these images ?
Calculate the aspect ratio (width / height, or vice-versa). I suggest dividing whichever is smaller by the other one, so you always get a number that is no greater than one.
Then define a threshold, as a number between 0 and 1. If the resulting division gives a result smaller than the threshold, you can consider the image a non-square.
Something along these lines...
var ratio = 1;
if(Height>Width)
{
ratio = (Height / Width);
}else{
ratio = (Width / Height);
}
var ThresHoldVal = 0.1; // 10% out.
if((Ratio-1) > ThresholdVal)
{
//Invalid.
}

Custom Marker icon Google Maps iOS with image in image? [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
I try to create many markers in map with icon is a png image like placeholder.
After that i want to set an other image inside of each placeholder.
It looks like this.
My problem is how to set image inside image of marker.
How to do that?
You would need to write code which takes the background image (eg the frame) and adds on the sub-image (eg the food picture), to create a combined UIImage. Then you could use the combined UIImage as the marker's icon.
Check out these questions for some examples of how to draw 2 UIImage objects into a single UIImage:
Draw another image on a UIImage
Attempting to draw image on top of another image using a touch event

Resources