[prev in list] [next in list] [prev in thread] [next in thread] 

List:       imagemagick-user
Subject:    Re: [magick-users] Writing images from raw data?
From:       Leonard Rosenthol <leonardr () lazerware ! com>
Date:       2002-05-30 2:14:05
[Download RAW message or body]

At 5:06 PM -0700 5/29/02, Tokuyasu, Taku wrote:
>I am primarily interested in writing 16-bit grayscale images, but I 
>would be happy to be able to write any image for starters.  I can do 
>so from pre-existing images, but I would like to be able to create 
>an image from raw pixel data.

	OK.


>1) Is ConstituteImage the correct/best method to use to create an 
>image from data?  (I will eventually be manipulating float arrays, 
>which is why I am data-centric).

	I don't know if it's the best way, but it's not the way that 
we do things internally in IM itself.  You can just create a new 
image (AllocateImage), fill in the necessary fields (image->rows, 
image->columns, etc.) and then fill in the pixels via 
SetPixelPackets().


>2) Do I have to deal with PixelPackets in this simple application? 

	YES!   That's how pixels are stored in IM.


>If so, what are the relevant data members in the case of grayscale 
>(or is grayscale just an RGB image with R=G=B)?

	Correct - it's an RGB image with all values being equal.


>3) Does "image" already have an associated ImageInfo struct?  If so, 
>how do I get at it (the "obvious" answer, GetImageInfo, doesn't do 
>this)?

	AllocateImage() will create an Image* from an ImageInfo.  If 
you need a new/default ImageInfo by doing a CloneImageInfo(NULL).


>4) The assertion failure seems to be related to fopen - do I have to 
>open something manually first (I've checked to make sure the 
>"basic.tif" file does not exist yet, so there is no issue with 
>overwriting).
>

	Nope, just do a WriteImage().


Leonard
-- 
---------------------------------------------------------------------------
Leonard Rosenthol                            <mailto:leonardr@lazerware.com>
                      			     <http://www.lazerware.com>
[Attachment #3 (text/html)]

<!doctype html public "-//W3C//DTD W3 HTML//EN">
<html><head><style type="text/css"><!--
blockquote, dl, ul, ol, li { padding-top: 0 ; padding-bottom: 0 }
 --></style><title>Re: [magick-users] Writing images from raw
data?</title></head><body>
<div>At 5:06 PM -0700 5/29/02, Tokuyasu, Taku wrote:</div>
<blockquote type="cite" cite><font face="Arial" size="-1">I am
primarily interested in writing&nbsp;16-bit grayscale images, but I
would be happy to be able to write any image for starters.&nbsp; I can
do so from pre-existing images, but I would like to be able to create
an image from raw pixel data.</font></blockquote>
<div><br></div>
<div><x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</x-tab>OK.</div>
<div><br></div>
<div><br></div>
<blockquote type="cite" cite><font face="Arial" size="-1">1) Is
ConstituteImage the correct/best method to use to create an image from
data?&nbsp; (I will eventually be manipulating float arrays, which is
why I am data-centric).</font></blockquote>
<div><br></div>
<div><x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </x-tab>I don't
know if it's the best way, but it's not the way that we do things
internally in IM itself.&nbsp; You can just create a new image
(AllocateImage), fill in the necessary fields (image-&gt;rows,
image-&gt;columns, etc.) and then fill in the pixels via
SetPixelPackets().</div>
<div><br></div>
<div><br></div>
<blockquote type="cite" cite><font face="Arial" size="-1">2) Do I have
to deal with PixelPackets in this simple
application?&nbsp;</font></blockquote>
<div><br></div>
<div><x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</x-tab>YES!&nbsp;&nbsp; That's how pixels are stored in IM.</div>
<div><br></div>
<div><br></div>
<blockquote type="cite" cite><font face="Arial" size="-1">If so, what
are the relevant data members in the case of grayscale (or is
grayscale just an RGB image with R=G=B)?</font></blockquote>
<div><br></div>
<div><x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </x-tab>Correct
- it's an RGB image with all values being equal.</div>
<div><br></div>
<div><br></div>
<blockquote type="cite" cite><font face="Arial" size="-1">3)&nbsp;Does
&quot;image&quot; already have an associated ImageInfo struct?&nbsp;
If so, how do I get at it&nbsp;(the &quot;obvious&quot; answer,
GetImageInfo, doesn't do this)?</font></blockquote>
<div><br></div>
<div><x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</x-tab>AllocateImage() will create an Image* from an ImageInfo.&nbsp;
If you need a new/default ImageInfo by doing a
CloneImageInfo(NULL).</div>
<div><br></div>
<div><br></div>
<blockquote type="cite" cite><font face="Arial" size="-1">4) The
assertion failure seems to be related to fopen - do I have to open
something manually first (I've checked to make sure the
&quot;basic.tif&quot; file does not exist yet, so there is no issue
with overwriting).</font></blockquote>
<blockquote type="cite" cite>&nbsp;</blockquote>
<div><br></div>
<div><x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </x-tab>Nope,
just do a WriteImage().</div>
<div><br></div>
<div><br></div>
<div>Leonard</div>
<x-sigsep><pre>-- 
</pre></x-sigsep>
<div
>--------------------------------------------------------------------<span
></span>-------<br>
Leonard
Rosenthol&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span
></span
>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span
></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&lt;mailto:leonardr@lazerware.com&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span
></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<x-tab
>&nbsp;&nbsp;&nbsp;
</x-tab><x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</x-tab><x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</x-tab>&nbsp;&nbsp;&nbsp;&nbsp;
&lt;http://www.lazerware.com&gt;</div>
</body>
</html>
_______________________________________________
Magick-users mailing list
Magick-users@imagemagick.org
http://studio.imagemagick.org/mailman/listinfo/magick-users

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic