Re: Combining two NSImages into one
Re: Combining two NSImages into one
- Subject: Re: Combining two NSImages into one
- From: Graeme Nattress <email@hidden>
- Date: Tue, 29 Oct 2002 08:15:20 -0500
I had a similar problem - to join images together. The images in my
case are 3d renders that have been split up so that they render faster.
The task was to join them back together again. I did it with
NSBitmapImageReps like this:
- (void)copySectionFrom:(NSBitmapImageRep *)copyFrom blockXCoord:(int)x
blockYCoord:(int)y
{
//Copy the data from copyFrom to self, altering self directly.
//Don't care about the image data in terms of colour and alpha, just do
a direct copy across
//using C pointers.
//This means that both source and destination must be "similar" in
terms of alpha and bit depth.
//get the source and destination size info
int bytesPerRowCopyFrom = [copyFrom bytesPerRow];
int bytesPerRowCopyTo = [self bytesPerRow];
int yheight = [copyFrom size].height;
unsigned char *dataPointerFrom, *dataPointerTo;
//make pointers to the actual bitmap data in memory
dataPointerFrom = [copyFrom bitmapData];
dataPointerTo = [self bitmapData];
int item, row;
int byteC, byteP;
//loop over rows
for (row = 0; row < yheight; row++) {
//loop over each byte of each row
for (item = 0; item < bytesPerRowCopyFrom; item++) {
//calculate the pointers to the bytes to be copied
byteC = (row * bytesPerRowCopyFrom) + item;
byteP = (row * bytesPerRowCopyTo) + item;
//do the byte copy, byte by byte, offsetting the destination point
based on the block\
//x, y coordinates of the copy from block.
dataPointerTo[byteP + (bytesPerRowCopyFrom * x) + (yheight * y)] =
dataPointerFrom[byteC];
}
}
}
On Tuesday, October 29, 2002, at 12:17 am,
email@hidden wrote:
>
Re: Combining two NSImages into one
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.