Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
RE: CGContextDrawImage Drawing Image Upside Down
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: CGContextDrawImage Drawing Image Upside Down

Title: RE: CGContextDrawImage Drawing Image Upside Down


Thanks for your reply.

If I don't flip the co-ordinate system then my JPEG appears correctly but in the wrong position as my 'y' co-ordinate is now from the bottom of the window rather than the top (ie: like QuickDraw).

According to QA1009 I need to flip the co-ordinate system if I want to work the same way as QuickDraw (which I assume means that 0,0 means top-left rather than bottom-left).

What appears to be happening is that CGContextDrawImage is always drawing from the bottom of the JPEG to the top of the JPEG. This is okay when the co-ordinate system is untouched as it is also bottom to top. However, when the co-ordinate system is flipped the bottom line of the JPEG is drawn at my start 'y' position and the additional JPEG lines are then drawn down the window.

I guess I could just leave the co-ordinate system untouched and calculate a new 'y' co-ordinate to draw the JPEG but it does make my code messier as I am dealing with two different co-ordinate systems within the window.


-----Original Message-----
From: Scott Thompson [mailto:email@hidden]
Sent: Tue 28/03/2006 9:03 PM
To: Kevin Gale
Cc: email@hidden
Subject: Re: CGContextDrawImage Drawing Image Upside Down

On Mar 28, 2006, at 12:48 PM, Kevin Gale wrote:

> Hi.
> I'm using CGContextDrawImage() in a plug-in i'm creating to draw a 
> JPEG into a window created by the source application (MacOS X 10.3.9)
> I have followed the documentation which states that I should flip 
> the co-ordinate system so that it is the same as Quickdraw. 
> Although this makes my image draw in the correct position within 
> the window it is upside down.
> I guess I need to perform a transformation when drawing the image 
> but i'm new to Core Graphics so not sure how to proceed.
> I've provided the code from my test function below.
> Can anybody help.
> Regards,
> Kev.
If you've added code to transform the image and it's drawing flipped 
then you should not have needed to flip the image in the first place.

Where is the context that you are drawing into coming from?

You are only likely to have  to flip the context if it is coming from 
the HIView system.  If it's a context that you've created yourself 
(i.e. using CGBitmapContextCreate or  QDBeginCGContext) then you will 
not need to flip before using core graphics to draw, but you will 
have to measure your coordinates from the lower left corner of the 

For more information see "Quartz 2D Graphics for Mac OS X 
Developers".  Chapter 4 discusses the relationship between user space 
and the device.  Chapter 8 discusses drawing with images.

Alternatively you can also look in "Programming with Quartz" in 
Chapters 5 and 9.




E-MAIL DISCLAIMER: The information in this email is confidential and may be legally privileged. It is intended solely for the addressee. Access to this email by anyone else is unauthorised. If you are not the intended recipient, any disclosure, copying, distribution or any action taken or omitted to be taken in reliance on it, is prohibited and may be unlawful. All information provided, including but not limited to, quotations, system specifications and suggestions concerning hardware/software (and services) configurations are strictly subject to our standard terms and conditions of business, copies of which are available on request.

This e-mail has been scanned for all viruses by Star Internet. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
Do not post admin requests to the list. They will be ignored.
Carbon-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

 >CGContextDrawImage Drawing Image Upside Down (From: "Kevin Gale" <email@hidden>)
 >Re: CGContextDrawImage Drawing Image Upside Down (From: Scott Thompson <email@hidden>)

Visit the Apple Store online or at retail locations.

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.