nsview - Cocoa working with a texture atlas -
i'm loading texture atlas app using drawrect of nsview subview:
nsimage *imagefrombundle = [nsimage imagenamed:@"sheet1.png"]; [self setneedsdisplay:yes]; nssize isize = [imagefrombundle size]; [imagefrombundle drawinrect:[self bounds] fromrect:nsmakerect(0.0, 0.0, isize.width, isize.height) operation: nscompositecopy fraction:1.0];
this works fine displays whole texture atlas. how zone in on specific part of image? image 1800x1200 pixels, each image 180x250pixels, image 1 x=0, y=0, w=180, h=250, 2 x=180, y=0, w=180, h=250, , on.
i tried changing x, y, w, h in above output black image. appreciated.
edit: solved it, though i'm not sure if correct:
i changed file 1100x1100 (this has no effect on solution reflect in answer wanted note it. , targeting wrong area (x,y) of image , passing wrong size target. new code looks so:
[imagefrombundle drawinrect:[self bounds] fromrect:nsmakerect(0.0, 950.0, 175.0, 250.0) operation: nscompositecopy fraction:1.0];
if there different way of accomplishing love see it. thanks.
Comments
Post a Comment