473,396 Members | 2,151 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

creating an image from an array of raw data

Can the GD library do this?

I have an array of numbers (which I shall be manipulating
server-side), which I wish to convert into an image. The elements of
the array are essentially the 1D subscripts of a 256*256 image.
I've been looking at the GD library functions all day, but I can't
seem to translate the array to a jpeg or png or whatever. (The GD
library functions are working though.) It seems that creating an image
from another image is easy, but not from the raw data.

How can I make a greyscale image out of this array, scaled to the
maximum pixel?

Dave Higgins
PHP 4.3.4, Apache(Unix)1.3.22, GD 2.0.15
Jul 17 '05 #1
1 3652
go**********@higginsnet.com (Dave Higgins) wrote in message news:<d8**************************@posting.google. com>...
Can the GD library do this?

I have an array of numbers (which I shall be manipulating
server-side), which I wish to convert into an image. The elements of
the array are essentially the 1D subscripts of a 256*256 image.
I've been looking at the GD library functions all day, but I can't
seem to translate the array to a jpeg or png or whatever. (The GD
library functions are working though.) It seems that creating an image
from another image is easy, but not from the raw data.

How can I make a greyscale image out of this array, scaled to the
maximum pixel?

Dave Higgins
PHP 4.3.4, Apache(Unix)1.3.22, GD 2.0.15

If I understand you correctly, this is one way to do:

<?php
header("Content-type: image/gif");
$im = ImageCreate(256, 256);

FOR LOOP TO ITERATE ARRAY {
$R=$G=$B=YOUR_GRAYSCALE_ARRAY[$i];
$color = ImageColorAllocate($im, $R, $G, $B);

// Set a pixel where you want
ImageSetPixel($im, $x, $y, $color);
}

// Print and destory
ImageGIF($im);
ImageDestory($im);
?>

Thats it!
Jul 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: dave | last post by:
Hello there, I am at my wit's end ! I have used the following script succesfully to upload an image to my web space. But what I really want to be able to do is to update an existing record in a...
2
by: Tommie Nygren | last post by:
For different reasons I am reading an array of bytes from a file in my ..jar-file and from this I want to create a PNG image using Image.createImage(myArray, 0 , myArray.length). I had a...
6
by: Edwin Young | last post by:
Hi, I'm writing a fractal-generating program in a mixture of C and Python. Python handles all the GUI parts using PyGTK. After finishing the calculations, I have a buffer containing the RGB data...
7
by: lgbjr | last post by:
Hello All, I¡¯m using a context menu associated with some pictureboxes to provide copy/paste functionality. Copying the image to the clipboard was easy. But pasting an image from the clipboard...
8
by: ctiggerf | last post by:
I was hopeing someone could help me out here. Been stumped on this one all day. This function 1. Checks uploaded files. 2. Creates two resized images from each (a full size, and a...
9
by: colin | last post by:
Hi, I have all the components of a .bmp file in memory wich i need to write to a .bmp file, (or other convenient image file) ie i have 256 color pallete of RGBquads and array of 8bit pixels, I...
1
by: Ramdas | last post by:
Any ideas how we can create a color gradient using Python Imaging Library. Has any got some sample code that can give me some idea. I need to create a horizontal and vertical color gradient for a...
2
by: oswald.harry | last post by:
hi i am reading a set of jpeg files(RGB) and extracts the pixel values as longs.i want to create a 2d array with numof rows=numof images and numof cols=numof pixels in each image.ie each row of...
0
Debadatta Mishra
by: Debadatta Mishra | last post by:
Introduction In this article I will provide you an approach to manipulate an image file. This article gives you an insight into some tricks in java so that you can conceal sensitive information...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.