Page 1 of 1
simples of questions
Posted: 2009-08-18T21:33:43-07:00
by jamesb
How do I create a new image, not from a file, using Magick Core? It needs to be 50k x 50k. I then need to set the pixels, in blocks of 16x16, and save the file. I have searched this forum, and the website, and not found anything that involves creating an image from scratch - only loading images and modifying them. Be grateful for some simple example code. Thanks.
James
Re: simples of questions
Posted: 2009-08-19T00:26:34-07:00
by anthony
Create an image with...
Code: Select all
convert -size 50000x50000 xc:black save_image.png
to also set teh top left 16x16 area to red do...
Code: Select all
convert -size 50000x50000 xc:black \
-draw 'fill red -rectangle 0,0 15,15' \
save_image.png
However if ALL 16x16 blocks are solid colors. a better way may be to create your image as a single pixel, and -scale it by 1600%
for example generating a 160x160 image with just the top left corner red
can be create dby creating a 10x10 pixel image with just one pixel red!
create a TXT image file (See
http://www.imagemagick.org/Usage/files/#txt )
and call it "pixel_image.txt"
# ImageMagick pixel enumeration: 10,10,255,rgb
0,0: (255,0,0)
Now scale it
Code: Select all
convert pixel_image.txt -scale 1600% save_image.png
There are hundreds of ways of generating images.
See more in IM Examples, Canvases
http://www.imagemagick.org/Usage/canvas/
Re: simples of questions
Posted: 2009-08-19T09:35:38-07:00
by jamesb
I meant the C Magick Core interface. I just found the Architecture page and read that. What's missing is how to specify what format to save the file in, or rather, what specific version of the format. I want to save 64bit PNG, (RGBA 16bpc).
Thanks
Jamie
Re: simples of questions
Posted: 2009-08-19T10:28:18-07:00
by magick
To create a 50k x 50k image canvas use these MagickCore API calls:
Code: Select all
Image *image = AcquireImage( image_info );
if (SetImageExtent( image, 50*1024, 50*1024 ) == MagickFalse )
perror( "somethings wrong" );
Re: simples of questions
Posted: 2009-08-19T11:09:37-07:00
by jamesb
How to specify saving 16bpc PNG vs 8bpc? Or float TIFF vs 8bpc TIFF? Or RGBA vs RGB?
Re: simples of questions
Posted: 2009-08-19T11:51:48-07:00
by magick
Use SetImageDepth() to specify the image depth:
- SetImageDepth( image, 8 );
To produce float TIFF images, try:
- SetImageProperty( image, "quantum:format", "floating-point");
For RGBA images, use:
- SetImageAlphaChannel( image, ActivateAlphaChannel );