<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
How did you handle the alpha channel in (for example) gif images?<br>
<br>
ExceptionInfo *exception;<br>
Image *image;<br>
ImageInfo *image_info;<br>
long x, y;<br>
const PixelPacket *p;<br>
QuantizeInfo *qinfo;<br>
unsigned char *q;<br>
unsigned char *imgbuf;<br>
<br>
/*<br>
* Initialize the image info structure and read an image.<br>
*/<br>
MagickCoreGenesis(*argv,MagickTrue);<br>
exception = AcquireExceptionInfo();<br>
image_info = CloneImageInfo((ImageInfo *) NULL);<br>
(void) strcpy(image_info->filename,argv[1]);<br>
image = ReadImage(image_info,exception);<br>
if (exception->severity != UndefinedException)<br>
CatchException(exception);<br>
if (image == (Image *) NULL)<br>
exit(1);<br>
<br>
printf("rows = %ld, columns= %ld\n", image->rows,
image->columns);<br>
<br>
imgbuf = (unsigned char
*)malloc(image->rows*image->columns*sizeof(char)*4);<br>
q = imgbuf;<br>
for(y=0; y < (long) image->rows; y++)<br>
{<br>
p = GetVirtualPixels(image, 0, y, image->columns, 1,
exception);<br>
if( p == (const PixelPacket *)NULL )<br>
break;<br>
for( x = 0; x < (long) image->columns; x++)<br>
{<br>
*q = ScaleQuantumToChar(p->blue);<br>
q++;<br>
*q = ScaleQuantumToChar(p->green);<br>
q++;<br>
*q = ScaleQuantumToChar(p->red);<br>
q++;<br>
*q = ScaleQuantumToChar(p->opacity);<br>
q++;<br>
p++;<br>
}<br>
}<br>
<br>
Is this the right way?<br>
<br>
Juan Aranda<br>
<br>
Thomas Stover wrote:
<blockquote cite="mid:4989F21F.1040805@wsinnovations.com" type="cite">
<pre wrap="">A similar question came up on the gtk list the other day. Since you are
looking for a way to do it without using an additional library, this is
not your answer. However, I have been recommending people try
ImageMagick <a class="moz-txt-link-freetext" href="http://www.imagemagick.org/script/index.php">http://www.imagemagick.org/script/index.php</a> for "non png"
file formats and misc raster operations such as resize as a supplement
to cairo. If you want my demo I can post it here.
Out of curiosity, what are your reasons for not wanting another library?
I have seen allot of aversion to mixing libraries lately. As long as
licenses and technical details work out, to me that's how you bring some
real alchemy to the table.
</pre>
<blockquote type="cite">
<pre wrap="">From: Tor Lillqvist <a class="moz-txt-link-rfc2396E" href="mailto:tml@iki.fi"><tml@iki.fi></a>
Subject: Re: [cairo] how to import .BMP without other libs(GTK+ etc)?
</pre>
<blockquote type="cite">
<pre wrap="">we could do it with GTK+. However, is there some other way to import BMP or
dib in cairo without the suppot of other libs?
</pre>
</blockquote>
<pre wrap="">Not as far as I can see.
</pre>
<blockquote type="cite">
<pre wrap="">I had tried to do it whit cairo_image_surface_create_for_data, but failed. I could not see the right image.
</pre>
</blockquote>
<pre wrap="">Are you sure that the .bmp file you are reading actually is in a
(sub)format your code can handle? Didn't debugging (or adding
printouts...) tell you anything? There must be a lot of sample code
that reads .bmp out there, compare to the code of those... I know of
io-bmp.c in gtk+/gdk-pixbuf and GIMP's bmp-read.c.
A "throwaway" program I wrote to dump the contents of a .bmp file is
at <a class="moz-txt-link-freetext" href="http://pastebin.com/m6e96721e">http://pastebin.com/m6e96721e</a> . Unfortunately it compiles as such
only on Windows.
--tml
</pre>
</blockquote>
<pre wrap=""><!---->
_______________________________________________
cairo mailing list
<a class="moz-txt-link-abbreviated" href="mailto:cairo@cairographics.org">cairo@cairographics.org</a>
<a class="moz-txt-link-freetext" href="http://lists.cairographics.org/mailman/listinfo/cairo">http://lists.cairographics.org/mailman/listinfo/cairo</a>
</pre>
</blockquote>
<br>
</body>
</html>