<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:arial,helvetica,sans-serif;font-size:10pt"><div><br></div><div style="font-family: arial,helvetica,sans-serif; font-size: 10pt;"><br><div style="font-family: tahoma,new york,times,serif; font-size: 10pt;"><font face="Tahoma" size="2"><hr size="1"><b><span style="font-weight: bold;">From:</span></b> "insight-users-request@itk.org" <insight-users-request@itk.org><br><b><span style="font-weight: bold;">To:</span></b> insight-users@itk.org<br><b><span style="font-weight: bold;">Sent:</span></b> Thu, May 6, 2010 4:50:57 AM<br><b><span style="font-weight: bold;">Subject:</span></b> Insight-users Digest, Vol 73, Issue 19<br></font><br>Send Insight-users mailing list submissions to<br> <a ymailto="mailto:insight-users@itk.org" href="mailto:insight-users@itk.org">insight-users@itk.org</a><br><br>To subscribe or unsubscribe via the
World Wide Web, visit<br> <a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br>or, via email, send a message with subject or body 'help' to<br> <a ymailto="mailto:insight-users-request@itk.org" href="mailto:insight-users-request@itk.org">insight-users-request@itk.org</a><br><br>You can reach the person managing the list at<br> <a ymailto="mailto:insight-users-owner@itk.org" href="mailto:insight-users-owner@itk.org">insight-users-owner@itk.org</a><br><br>When replying, please edit your Subject line so it is more specific<br>than "Re: Contents of Insight-users digest..."<br><br><br>Today's Topics:<br><br> 1. Re: Using ImportFilter and PasteImageFilter (Quent)<br> 2. Re: Wrapping ITK in OSX 10.6 (Lassi Paavolainen)<br><br><br>----------------------------------------------------------------------<br><br>Message:
1<br>Date: Thu, 6 May 2010 00:30:13 -0700 (PDT)<br>From: Quent <<a ymailto="mailto:quentin.bezsilko@gmail.com" href="mailto:quentin.bezsilko@gmail.com">quentin.bezsilko@gmail.com</a>><br>Subject: Re: [Insight-users] Using ImportFilter and PasteImageFilter<br>To: <a ymailto="mailto:insight-users@itk.org" href="mailto:insight-users@itk.org">insight-users@itk.org</a><br>Message-ID: <<a ymailto="mailto:28470202.post@talk.nabble.com" href="mailto:28470202.post@talk.nabble.com">28470202.post@talk.nabble.com</a>><br>Content-Type: text/plain; charset=UTF-8<br><br>In the following lines:<br>-------------------------<br> unsigned long i, x;<br> float * fImage;<br> pixList =
[new2DViewer pixList];<br> for(i=0;i<[pixList count]; i++){<br>
curPix = [pixList objectAtIndex:i];<br> x = height * width;<br>
fImage = [curPix fImage];<br> while(x>0){<br>
*localBuffer = *fImage;<br> localBuffer++;<br>
cptLocalBuffer++;<br> fImage++;<br> x--;<br>
}<br> }<br>-----------------------<br><br>you are incrementing the pointer to your allocated buffer (localBuffer++). So, when you use it later in:<br><br>-----------------------<br> importFilter->SetImportPointer(localBuffer, numberOfPixels, true);<br>-----------------------<br><br>It is no longer pointing to the memory space you allocated but just beyond that leading to your unexpected crash. You should rewrite you pixel copy code to something like:<br><br>
-------------------------<br>
unsigned long i, x;<br>
x = height * width;<br>
float * fImage;<br>
float* tmpLocalBufferPtr;<br> tmpLocalBufferPtr = localBuffer;<br>
pixList =
[new2DViewer pixList];<br>
for(i=0;i<[pixList count]; i++){<br> memcpy( tmpLocalBufferPtr, [curPix fImage], x);<br>
tmpLocalBufferPtr += x;<br>
}<br>-----------------------<br><br>Todd Jensen<br></div></div>
</div></body></html>