This is probably a n00b question so I apologize in advance. I'm working with NSImage for the first time and basically I need to simply take a picture that is in my Resources folder, and have it display in an NSView/NSImageWell when a button is clicked.
NSImage *image = [[NSImage alloc] initWithContentsOfFile:@"tiles.PNG"];
if ( [ima...
It was suggested that I use this line of code to call an image from my resources folder/project bundle. I also see it being used exactly like this on many different website tutorials.
NSBundle *mb=[NSBundle mainBundle];
NSString *fp=[mb pathForResource:@"topimage" ofType:@"PNG"];
NSImage *image=[NSImage initWithContentsOfFile:fp];
...
I need to get a CGIImageRef from an NSImage. Is there an easy way to do this in Cocoa for Mac OS X?
...
So I'm trying to duplicate the SourceView example in my app. I can generate the source list perfectly, fine. I can also expand the containers, and everything is displayed fine. However, when I select an item in the list, the app crashes with an EXC_BAD_ACCESS.
Backtrace
#0 0x7fff86532340 in objc_msgSend_vtable14
#1 0x7fff8508f622 in ...
I have an jpeg image and I want to be able to incrementally compress it using Cocoa/Core Image/Core Graphics. For example, I have A.jpg (3MB), I compress A and get B.jpg (1MB), compress B and get C.jpg (400KB), and so on till the image can't be compressed anymore.
I am trying to use NSBitmapImageRep representationUsingType:properties w...
I am having a problem that is eating me alive. I really hope I am just missing something small here. It appears to be a rather "n00b" issue.
I have a blank NSImageView that I want to display a picture when a button is pressed — simple as that.
Here is my line of coding
NSBundle *mb = [NSBundle mainBundle];
NSString *fp = [mb pathForRe...
I am trying to create a NSImage or NSImageCell with rounded corners inside a NSTableView. I can't get anything to work. Here is the best I have so far inside my custom NSCell:
- (void)drawInteriorWithFrame:(NSRect)frame inView:(NSView *)controlView {
if (thumbnailLink) {
NSURL *url = [NSURL URLWithString:thumbnailLink];
if (url) ...
I have a Cocoa app that embeds a WebView. The WebView loads html elements including images. I have the textual links for the images (e.g. "http://www.domain.com/path/image.jpg"), but what I want is the image data itself so I can put it in an NSData object and ship it off to Growl. The WebView must have this data since it has downloaded a...
I am trying to make a simple document-based cocoa application that can save and load images in pdf files.
For the save part, I am using
- (NSData *)dataOfType:(NSString *)typeName error:(NSError **)outError
{
return [imageView dataWithPDFInsideRect:[imageView bounds]];
}
And this works, the image could be saved to a PDF file.
Fo...
I have created an NSImage object, and ideally would like to determine how many of each pixels colour it contains. Is this possible?
...
This doesn't do anything:
NSImage* testImage = [[NSImage alloc] initWithSize:NSMakeSize(2.0,2.0)];
[testImage lockFocus];
[[NSImage imageNamed:@"testImage"] drawAtPoint:NSMakePoint(1.0,1.0) fromRect:NSZeroRect operation:NSCompositeCopy fraction:1.0];
[testImage unlockFocus];
[levelView setImage:testImage];
...but this does:
[levelV...
I have an NSImage and want to replace one color in it with another (e.g. replace all the blue with a green colour) Is there an easy way to do this and if not, how could I get this functionality?
...
I'm trying to draw a standard NSImage in white instead of black. The following works fine for drawing the image in black in the current NSGraphicsContext:
NSImage* image = [NSImage imageNamed:NSImageNameEnterFullScreenTemplate];
[image drawInRect:r fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:1.0];
I expected NSComposi...
I need to create an image badge in Cocoa. Basically I need to take two images one smaller then the other and overlay the smaller image over the larger image with a certain offset. Does Cocoa provide any utility to make this sort of thing easier?
...
Why is this code setting artistImage to an image with 0 width and 0 height?
NSURL *artistImageURL = [NSURL URLWithString:@"http://userserve-ak.last.fm/serve/252/8581581.jpg"];
NSImage *artistImage = [[NSImage alloc] initWithContentsOfURL:artistImageURL];
...
Following situation:
I have an instance of my NSObject sublcassed object. One of it's properties is a NSImage. After instanciating the object I convert it with NSKeyedArchiver to data, send it over the network, unarchive it with NSKeyedUnarchiver and display the image in a NSImageView (setAnimates: YES). Until here there are no problems...
When I try to crop an image using NSImage's imageFromRect, I get an EXEC_BAD_ACCESS crash about 50% of the time. This is something that runs on startup (triggered in an awakeFromNib), so the environment shouldn't be changing. I am not sure why it crashes one one launch and not another. When I have a breakpoint set before I crop the image...
I'm trying to load an image into my NSImageView/NSScrollView and display it at actual size, but the image mysteriously ends up getting displayed at about half-size. I thought at first it might be being reduced to fit into some kind of constraints of the frame etc., but soon realised this couldn't be right because if I physically enlarge ...
I have to make a prototype application where I superimpose a small image over the file icons of a given folder.
Let's say I have a folder /MyDocuments/
and there are three files /MyDocuments/Doc1.rtf /MyDocuments/Doc1.pdf and /MyDocuments/Doc1.jpg
and I have an image myicon.png, now I have to superimpose this image myicon.png over the fi...
Assume I load an NSImage of dimensions 2000x2000 and display only a portion of the picture inside an NSScrollView with frame size 500x300. How can I calculate the distance between the images 0,0 origin and the views 0,0 origin (so I can determine the x,y coordinates of the view relative to the whole image)?
Thanks in advance :-)
...