How to sample a color within an image - objective-c

I'm trying to implement some sort of eyedropper that can sample pixel color in an image and save that as an RGB or CMYK color value. Ideally it would be draggable, and perhaps function something like the magnifying loop does. If anyone can point me in the direction of code or a component that would help allot.
Thanks

Use the function NSReadPixel which gives you the color of the passed in point

To get a pixel color you can use a category on UIView: https://github.com/ivanzoid/ikit/tree/master/UIView%2BColorOfPoint
For draggabel behaviour you should use UIPanGestureRecognizer.

Related

How to create a circular slider with breakpoints?

I am new to react-native and i want to achieve the below design in react-native
The blue circle is a slider to chose the date(Date Picker)
The circle inside the slider(Date Picker) changes color when the date is changed
and finally an image inside the circle.
it would be great if anyone could provide links for reference or a library which i can use to create the design shown in the image.
thanks in advance.
you have to create a custom SVG Slider just like this one
I have created a sample for you take a look
react-native-circular-slider-with-breakpoints
Well this is a custom slider which has some break point values. As the slider changes there is a change in the state and based on that the below description view is rendered.
Use this slider and give some css colors and styles to make it round

How to compare pixel colour with pixel by pixel using CGPoint in UIImage

In my project I need to remove selected colour like wand tool.For this i was used flood fill algorithm(Flood fill).but it was not working properly for colour comparison(pixel by pixel).can any one suggest the solution.
In below images i need to remove background colour only(expected).
output Result.
can any one please help me with code Or example.

Circular images

In my application, users are allowed to choose a picture they want and this picture shows up in a picturebox.
I want to know if there was a way so that this picture that they select becomes circular instead of a square?
I want all images they select to be circle shaped.
Is there anyway to do this? Doesn't even have to be a picturebox control, anything that can accomplish this is fine
I tried this with no luck - http://www.codeproject.com/Questions/430531/circle-shaped-picture-box
Not the smartest way, but worked for me in similar task. If your picturebox is fixed size, you can create "mask" which will hide the corners.
Just draw an image in PNG with transparent circle in the middle and make the rest same color as your form. Use this image as Image propperty of each imagebox and set your image as "backgroundImage" property. This way, the image will look circle-shaped.
If you need imageboxes of different size, you can create the circle mask programmatically.
EDIT: If you will prepare a calculation of circle, you can also use it to "crop" the images to circle shape. It all depends on what you want to do with these images later.
Do you need to use them later in circle or rectangle shape?

An NSProgressIndicator with a different colour in the drawn bar

I'd like to change the color of the default gradient that is drawn inside the NSProgressIndicator bar. What's the easiest approach?
The easiest way is to change the HUE....refer the screen shot for better understanding...
Then you will have the Progress bar :
As suggested in this answer, you could apply a Core Image filter to recolour it. That'd be the easiest way, as you wouldn't have to animate it yourself.
If you wanted a completely different look, then override drawRect: and draw whatever you want, using [self doubleValue] and [self maxValue] to find out where to draw. That won't get you any animation or gradients for free though.
try this code. extract YRKSpinningProgressIndicator class and use it as as-usual progress indicator
I was trying to change de Hue as others said, but I was getting a lot of issues to get the right specific color i wanted. Maybe I just don't understand the color system too much...
But what did worked for me, and seems to be the most direct way to get a specific color, was using the CIColorMonochrome filter, where You can set any RGB color you want:
and programmatically:
let myCustomColor: CIColor(red: 10, green: 10, blue: 10)
if let colorMonochrome = CIFilter(name: "CIColorMonochrome", parameters: [kCIInputColorKey: myCustomColor]) {
progressIndicator.contentFilters.append(colorMonochrome)
}

How to create letterpress effect?

I'm looking to implement something like the famous "letterpress" effect in my application. Here's what I'm talking about: (just a quick example made in PShop)
As you can see, it looks like it's pressed into the background. I wonder if it's possible to do something like this on the Mac dynamically. Is there a way? Thanks!
You can do the gradient fill portion of the text using the code I provide in this answer. Check the coordinate space first, because I described that for the iPhone, which has an inverted Y axis when compared to the Mac's normal Quartz coordinates.
The text is first used to create a clipping path, and the gradient is drawn within that path.
As far as the internal shadow, you might be able to draw this after the gradient is drawn by using CGContextSetShadowWithColor() with an appropriate downward offset and black color, then drawing the text again using just the stroke of the text. deanWombourne has some sample code for a similar task in his answer here.
Draw the text with a normal font to create a black and white bitmap of the text.
Draw another image that is is the same size and completely filled with the gray-to-white gradient you have above.
Create a completely white image with the same size as your other images.
Draw your back and white text image (1) onto the white image (3) with NSCompositeDestinationOut.
This gives you a white image with your text cut out.
Draw the white image with the text cut out on top of the gradient image and apply a shadow while drawing.