Skip to content

Commit

Permalink
fix draw_image behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
stal888 committed May 22, 2015
1 parent 0d8fd57 commit f3bec7d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion cocoa/drawing.m
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,8 @@ void enddraw(int x, int y, int width, int height) {
void draw_image(const UTOX_NATIVE_IMAGE *image, int x, int y, uint32_t width, uint32_t height, uint32_t imgx, uint32_t imgy) {
DRAW_TARGET_CHK()

//debug("%lu %lu %lf", imgx, imgy, image->scale);

CGFloat sz = currently_drawing_into_view.frame.size.height;
CGRect rect = {
.origin = {
Expand All @@ -518,5 +520,7 @@ void draw_image(const UTOX_NATIVE_IMAGE *image, int x, int y, uint32_t width, ui
};

CGContextRef this = [NSGraphicsContext currentContext].graphicsPort;
CGContextDrawImage(this, rect, image->image);
CGImageRef di = CGImageCreateWithImageInRect(image->image, (CGRect){imgx, imgy, width / image->scale, height / image->scale});
CGContextDrawImage(this, rect, di);
CFRelease(di);
}

0 comments on commit f3bec7d

Please sign in to comment.