<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv=Content-Type content="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 11 (filtered medium)">
<style>
<!--
/* Font Definitions */
@font-face
        {font-family:SimSun;
        panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
        {font-family:Fixedsys;
        panose-1:0 0 0 0 0 0 0 0 0 0;}
@font-face
        {font-family:SimSun;
        panose-1:2 1 6 0 3 1 1 1 1 1;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman";}
a:link, span.MsoHyperlink
        {color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:Arial;
        color:windowtext;}
@page Section1
        {size:8.5in 11.0in;
        margin:1.0in 1.25in 1.0in 1.25in;}
div.Section1
        {page:Section1;}
/* List Definitions */
@list l0
        {mso-list-id:2129811295;
        mso-list-type:hybrid;
        mso-list-template-ids:-95232514 67698703 67698713 67698715 67698703 67698713 67698715 67698703 67698713 67698715;}
@list l0:level1
        {mso-level-tab-stop:.5in;
        mso-level-number-position:left;
        text-indent:-.25in;}
ol
        {margin-bottom:0in;}
ul
        {margin-bottom:0in;}
-->
</style>
</head>
<body lang=EN-US link=blue vlink=purple>
<div class=Section1>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'>Dear all ITK users and developers;<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'>I am trying to getting the image buffer and input it into a
OpenGL function </span></font><font size=2 face=Fixedsys><span
style='font-size:10.0pt;font-family:Fixedsys'>gluScaleImage </span></font><font
size=2 face=Arial><span style='font-size:10.0pt;font-family:Arial'>to resize
the image. Unfortunately my code does not work despite my many times try. The
major part of the code is listed as follows:<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'>……<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 color=blue
face=Fixedsys><span style='font-size:11.0pt;font-family:Fixedsys;color:blue'>try<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face=Fixedsys><span
style='font-size:11.0pt;font-family:Fixedsys'> {<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face=Fixedsys><span
style='font-size:11.0pt;font-family:Fixedsys'> reader->Update();<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face=Fixedsys><span
style='font-size:11.0pt;font-family:Fixedsys'> }<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face=Fixedsys><span
style='font-size:11.0pt;font-family:Fixedsys'> <font
color=blue><span style='color:blue'>catch</span></font> (itk::ExceptionObject
& err)<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face=Fixedsys><span
style='font-size:11.0pt;font-family:Fixedsys'> {<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face=Fixedsys><span
style='font-size:11.0pt;font-family:Fixedsys'> std::cerr
<< "exception in file reader " << std::endl;<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face=Fixedsys><span
style='font-size:11.0pt;font-family:Fixedsys'> std::cerr
<< err << std::endl;<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Fixedsys><span style='font-size:11.0pt;
font-family:Fixedsys'> <font
color=blue><span style='color:blue'>return</span></font> ;<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face=Fixedsys><span
style='font-size:11.0pt;font-family:Fixedsys'> }<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:11.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face=Fixedsys><span
style='font-size:11.0pt;font-family:Fixedsys'>InputImageType::Pointer image =
reader->GetOutput() ;<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=blue face=Fixedsys><span
style='font-size:11.0pt;font-family:Fixedsys;color:blue'>const</span></font><font
size=2 face=Fixedsys><span style='font-size:11.0pt;font-family:Fixedsys'>
InputImageType::RegionType &region = image->GetBufferedRegion() ;<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Fixedsys><span style='font-size:11.0pt;
font-family:Fixedsys'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Fixedsys><span style='font-size:11.0pt;
font-family:Fixedsys'>// image size<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 color=blue
face=Fixedsys><span style='font-size:11.0pt;font-family:Fixedsys;color:blue'>unsigned</span></font><font
size=2 face=Fixedsys><span style='font-size:11.0pt;font-family:Fixedsys'> <font
color=blue><span style='color:blue'>long</span></font> lwidth =
image->GetBufferedRegion().GetSize()[0] ;<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=blue face=Fixedsys><span
style='font-size:11.0pt;font-family:Fixedsys;color:blue'>unsigned</span></font><font
size=2 face=Fixedsys><span style='font-size:11.0pt;font-family:Fixedsys'> <font
color=blue><span style='color:blue'>long</span></font> lheight =
image->GetBufferedRegion().GetSize()[1] ;<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Fixedsys><span style='font-size:11.0pt;
font-family:Fixedsys'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Fixedsys><span style='font-size:11.0pt;
font-family:Fixedsys'>// set up new size<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=blue face=Fixedsys><span
style='font-size:11.0pt;font-family:Fixedsys;color:blue'>double </span></font><font
size=2 face=Fixedsys><span style='font-size:11.0pt;font-family:Fixedsys'>factor
= 0.5 ;<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=blue face=Fixedsys><span
style='font-size:11.0pt;font-family:Fixedsys;color:blue'>int</span></font><font
size=2 face=Fixedsys><span style='font-size:11.0pt;font-family:Fixedsys'> nNewWidth
= (<font color=blue><span style='color:blue'>int</span></font>)lwidth * factor;<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=blue face=Fixedsys><span
style='font-size:11.0pt;font-family:Fixedsys;color:blue'>int</span></font><font
size=2 face=Fixedsys><span style='font-size:11.0pt;font-family:Fixedsys'> nNewHeight
= (<font color=blue><span style='color:blue'>int</span></font>)lheight *
factor;<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=blue face=Fixedsys><span
style='font-size:11.0pt;font-family:Fixedsys;color:blue'>unsigned char</span></font><font
size=2 face=Fixedsys><span style='font-size:11.0pt;font-family:Fixedsys'> rasterNew
= <font color=blue><span style='color:blue'>new</span></font> <font color=blue><span
style='color:blue'>unsigned</span></font> <font color=blue><span
style='color:blue'>char</span></font> [nNewHeight * nNewWidth] ;<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Fixedsys><span style='font-size:11.0pt;
font-family:Fixedsys'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Fixedsys><span style='font-size:11.0pt;
font-family:Fixedsys'>// resize the image buffer<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 color=blue
face=Fixedsys><span style='font-size:11.0pt;font-family:Fixedsys;color:blue'>int</span></font><font
size=2 face=Fixedsys><span style='font-size:11.0pt;font-family:Fixedsys'>
iscale = gluScaleImage(GL_RGBA, (GLint)lwidth, (GLint)lheight,
GL_UNSIGNED_BYTE, &region, (GLint)nNewWidth, (GLint)nNewHeight, GL_UNSIGNED_BYTE,
rasterNew ) ;<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Fixedsys><span style='font-size:11.0pt;
font-family:Fixedsys'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'>But the output of the function iscale=</span></font><font
size=2 face=Fixedsys><span style='font-size:11.0pt;font-family:Fixedsys'>gluScaleImage
</span></font><font size=2 face=Arial><span style='font-size:11.0pt;font-family:
Arial'>is 1285</span></font><font size=2 face=Arial><span style='font-size:
10.0pt;font-family:Arial'>. I also tried to use </span></font><font size=2
face=Fixedsys><span style='font-size:11.0pt;font-family:Fixedsys'>InputPixelType
*pointer = image->GetBufferPointer();. </span></font><font size=2
face=Arial><span style='font-size:10.0pt;font-family:Arial'>It does not work
either.<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'>My questions are:<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>
<ol style='margin-top:0in' start=1 type=1>
<li class=MsoNormal style='mso-list:l0 level1 lfo1'><font size=2 face=Arial><span
style='font-size:10.0pt;font-family:Arial'>How to get and reading the
buffer of the image after reading an image file? Is the method in the
above code correct?<o:p></o:p></span></font></li>
<li class=MsoNormal style='mso-list:l0 level1 lfo1'><font size=2 face=Arial><span
style='font-size:10.0pt;font-family:Arial'>What does it mean by the return
value 1285 of the OpenGL function (I used a DICOM image with unsigned char
type and it is successfully read by the code)? Is the first item (pixel format)
I set</span></font><font size=2 face=Fixedsys><span style='font-size:11.0pt;
font-family:Fixedsys'> GL_RGBA</span></font><font size=2 face=Arial><span
style='font-size:10.0pt;font-family:Arial'> correct? and how to fix the
problem?<o:p></o:p></span></font></li>
</ol>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'>Your kind help is greatly appreciated.<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'>Best regards,<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'>Sam<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'> <o:p></o:p></span></font></p>
</div>
</body>
</html>