1. [OT]Dynamic Image Generation

Hello list.

I am looking for a program.  I need to be able to pass it a string and 
it make the string into an image(bmp, jpeg, or gif).


I am on windows.

Any suggestions?

Thanks, 
   Robert Szalay

new topic     » topic index » view message » categorize

2. Re: [OT]Dynamic Image Generation

On Thu, 29 May 2003 09:36:47 +0000, Robert Szalay <robsz1 at hotpop.com>
wrote:

>Hello list.
>
>I am looking for a program.  I need to be able to pass it a string and=20
>it make the string into an image(bmp, jpeg, or gif).
>
>
>I am on windows.
>
>Any suggestions?
>
Hi Robert,
Not quite sure why you think this is off topic...
Anyway, this is all you need do for a bmp:

include win32lib.ew
constant bm=3Dcreate(Pixmap,"",0,0,0,100,30,0)

setPenColor(bm,LightGray)
drawRectangle(bm, 1, 0,0, 100, 30)
setPenColor(bm,Black)
setFont(bm, "Arial", 10, 0)
setPenPos(bm, 5, 5)
wPuts(bm,"Hello World")

If you want to save it to file,=20
heres an old [and slow] David Cuny routine:

function getRGB( atom a )	-- convert rgb atom to {rgb}
	return {and_bits(a,#FF),
			and_bits(a,#FF00)/#100,
			and_bits(a,#FF0000)/#10000}
end function

procedure savePixmapToFile( atom pixmap, sequence fName )
--save pixmap to bitmap file
integer at, cx, cy
sequence size, pal, bmp, pix
	-- get extent
	size =3D getExtent( pixmap )
	cx =3D size[1]
	cy =3D size[2]
	-- empty bitmap and pal
	bmp =3D repeat( repeat( 0, cx ), cy )
	pal =3D {}
	for y =3D 1 to cy do
		for x =3D 1 to cx do
			-- get a pixel
			pix =3D getRGB( getPixel( pixmap, x, y ) )
			-- in the pal?
			at =3D find( pix, pal )
			if at =3D 0 then
				-- add to pal
				pal =3D append( pal, pix )
				-- get index
				at =3D length( pal )
			end if
			-- add to bitmap
			bmp[y][x] =3D at - 1
		end for
	end for
	-- make at least 16 colors
	if length( pal ) < 16 then
		pal &=3D repeat( {0,0,0}, 16-length(pal) )
	end if
	if save_bitmap( {pal,bmp}, fName ) then
		warnErr( "Unable to save bitmap " & fName )
	end if
end procedure

In the above code call that with savePixmapToFile(bm,"test.bmp")

Pete

new topic     » goto parent     » topic index » view message » categorize

3. Re: [OT]Dynamic Image Generation

On Thursday 29 May 2003 05:36 am, you wrote:
>
>
> Hello list.
>
> I am looking for a program.  I need to be able to pass it a string and
> it make the string into an image(bmp, jpeg, or gif).

The question is a bit unclear - but if you want to pass a string,
for example: "Hello World" and have it come out as a .jpg with 
the words "Hello World" in a specific font on a specific background,
gd is what you need:
http://www.boutell.com/

Irv

new topic     » goto parent     » topic index » view message » categorize

4. Re: [OT]Dynamic Image Generation

----- Original Message -----
From: "Robert Szalay" <robsz1 at hotpop.com>
To: "EUforum" <EUforum at topica.com>
Subject: [OT]Dynamic Image Generation


>
>
> Hello list.
>
> I am looking for a program.  I need to be able to pass it a string and
> it make the string into an image(bmp, jpeg, or gif).
>
>
> I am on windows.
>
> Any suggestions?
>

Are you after a program or a routine?

What are you expecting the string to contain? The name of a file that
contains the image? Or coded image data, using ASCII characters I assume. Or
something else?

Why do you mention specific file formats? eg bmp,jpeg, gif. And how do they
relate to the 'string'?

Is the image to be displayed or sent to a file or both?

--
Derek.

new topic     » goto parent     » topic index » view message » categorize

5. Re: [OT]Dynamic Image Generation

On 29 May 2003, at 8:52, irvm at ellijay.com wrote:

> 
> 
> On Thursday 29 May 2003 05:36 am, you wrote:
> >
> >
> > Hello list.
> >
> > I am looking for a program.  I need to be able to pass it a string and
> > it make the string into an image(bmp, jpeg, or gif).
> 
> The question is a bit unclear - but if you want to pass a string,
> for example: "Hello World" and have it come out as a .jpg with 
> the words "Hello World" in a specific font on a specific background,
> gd is what you need:
> http://www.boutell.com/

That would be a really neat trick, you know? Might even beat using a 
background src tag for a browser window.

Kat

new topic     » goto parent     » topic index » view message » categorize

6. Re: [OT]Dynamic Image Generation

----- Original Message -----
From: "Robert Szalay" <robsz1 at hotpop.com>
To: "EUforum" <EUforum at topica.com>
Subject: RE: [OT]Dynamic Image Generation


>
>
> Ok.
>
> I guess it isnt really off topic.
>
> I mentioned the specific formats because this is a web project.
> I need it to be a format that will be supported in all browsers(so maybe
> bmp wouldnt be too good of a format.  I don't know if most browsers
> supports bmp's or not but I would think they do.).  I guess I should
> have mentioned that.  I would be happy with a program or a routine(but a
> routine would be better).  Another thing is that it has to be cross
> platform.  I need to pass it a string and it make an image out of it.
> i.e.:  I pass "TEsT" and it makes an image with "TEsT" in it.
>
> It is for a web signup system.  To prevent people from writing automated
> signup applications.  I beleive Google does this when you submit your
> url to them.
>

Ok, now this makes a lot more sense to me. Would FONT
face/size/fg-bg-colour/fg-bg-pattern be required as well as the text? Does
all the text need to be on one line or will multiple lines be required?

(** Note for budding programmers ** Get the specifications right before
coding the final solution. )


 make_text_image(outputname, "JPG", theText, "arial", 14, Bold, {Red, Pink},
{Black, White}, SMALLDOTS, CROSSHATCH)

--
Derek

new topic     » goto parent     » topic index » view message » categorize

7. Re: [OT]Dynamic Image Generation

With a webserver up and running, i will be somewhat interested in this too, 
for sending pics of characters in non-english fonts to people who don't have 
the correct fonts. Stringing them together as clumps of .png or .jpg might 
look bad.

Kat

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu