|[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]|
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.
From: Scott Thompson [mailto:email@hidden]
Sent: Tue 28/03/2006 9:03 PM
To: Kevin Gale
Subject: Re: CGContextDrawImage Drawing Image Upside Down
On Mar 28, 2006, at 12:48 PM, Kevin Gale wrote:
> 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.
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.
_______________________________________________ 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.
Copyright © 2011 Apple Inc. All rights reserved.