🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.mac.programmer.codewarrior
Article #665

How to crop image in powerplant

#665
From: wall
Date: Thu, 09 Oct 2003 09:25
45 lines
2690 bytes
I want to get the image part which I selected in the whole image.

this is the code i worte:

// create the selected rect's size GWorld - theSelectImageGWorld
// the orignal image GWorld - theImageGWorld
LGWorld*	theSelectImageGWorld = NEW LGWorld( theSelectRect,32 );
ThrowIfNil_( theSelectImageGWorld ); 

PixMapHandle	theOPixMapH = ::GetGWorldPixMap(
theImageGWorld->GetMacGWorld() );
PixMapHandle	theSelectPixMapH = ::GetGWorldPixMap(
theSelectImageGWorld->GetMacGWorld() );
Ptr theOBaseAddr = ::GetPixBaseAddr( theOPixMapH );
Ptr theSelectBaseAddr = ::GetPixBaseAddr( theSelectPixMapH );
short  theORowBytes = ::GetPixRowBytes( theOPixMapH );
short  theSelectRowBytes = ::GetPixRowBytes( theSelectPixMapH );

::LockPixels( theOPixMapH );
::LockPixels( theSelectPixMapH );
{
	Ptr		theSrcPtr, theDstPtr;
	for(short theY = mSelRectToImageOrignal.top; theY <=
mSelRectToImageOrignal.bottom; theY++)
	{
		theSrcPtr = theOBaseAddr + theORowBytes * theY;
		theSrcPtr += mSelRectToImageOrignal.left << 2;
		theDstPtr = theSelectBaseAddr + theSelectRowBytes * ( theY -
mSelRectToImageOrignal.top );
		for (short theX = mSelRectToImageOrignal.left; theX <=
mSelRectToImageOrignal.right; theX++)
		{
			* ((long*) theDstPtr) = * ((long*) theSrcPtr);
			theDstPtr += 4;
			theSrcPtr += 4;
		}	
	}		
}
::UnlockPixels( theOPixMapH );
::UnlockPixels( theSelectPixMapH );

who know where is error in this code. because sometime when the code
perform here,project will crash.

sorry, my english is very poor.
Technical Details
Message-ID: <7328a61a.0310090125.3fd8c2aa@posting.google.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!postnews1.google.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10bcce,84ab783dcdd87219,start
X-Google-Attributes: gid10bcce,public
X-Google-Thread: 11100c,84ab783dcdd87219,start
X-Google-Attributes: gid11100c,public
X-Google-Thread: f98ee,84ab783dcdd87219,start
X-Google-Attributes: gidf98ee,public
X-Google-Thread: f635e,84ab783dcdd87219,start
X-Google-Attributes: gidf635e,public
X-Google-ArrivalTime: 2003-10-09 02:25:34 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!postnews1.google.com!not-for-mail
From: heroin_c@hotmail.com (wall)
Newsgroups: comp.sys.mac.programmer.codewarrior,comp.os.ms-windows.programmer.tools.misc,codewarrior.mac,comp.sys.mac.programmer.tools
Subject: How to crop image in powerplant
Date: 9 Oct 2003 02:25:33 -0700
Organization: http://groups.google.com
Lines: 45
Message-ID: <7328a61a.0310090125.3fd8c2aa@posting.google.com>
NNTP-Posting-Host: 210.83.195.53
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
X-Trace: posting.google.com 1065691534 3656 127.0.0.1 (9 Oct 2003 09:25:34 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Thu, 9 Oct 2003 09:25:34 +0000 (UTC)