Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

text in image

Status
Not open for further replies.

reggler

Programmer
Nov 13, 2008
63
CA
Hi There,

I got an image with a bar code that gets generated automatically (modified code from and now i would like to add the content of the barcode in text below the bars...you know, when you look at the bar codes it usually says below the bar code what kind of information it contains... i wanna do the same but i don't want to display it in a text widget as the image gets exported and it will be used stand alone so i need to have the information in the image itself.
How do I write text into an image. Been googling around but I couldn't find anything... :(

Thanks for help!

Ron
Hours of planing can save weeks of coding
 
How are you building the image? Is it on a canvas widget? If so, you can "create" text on the canvas, too. I think a better solution would be to use a barcode font in text. I've seen several versions that include the underlying numbers.

_________________
Bob Rashkin
 
I'm not creating a canvas - i put the stuff duirectly into the image like this:
Code:
set im [image create photo -width $width -height $height]    
#and then I just go like
$im put black -to $offset 0 $x $height
I've already written the barcode routine and it's working fine with 3of9 encoding - I would like to go this way to have the ability to change the encoding "easily" rather than with a "barcode font"
All I'm looking for is to "$im put" some text - haven't figured out how i can do this tho...
Thanks fo your help!

Ron
Hours of planing can save weeks of coding
 
Well, I think the only thing you can do with an image is build the numerals out of pixels, since photo is a bit map (but, hey, it's only 10 proc's).

_________________
Bob Rashkin
 
What??? lol....no dude... haha okay,

how about creating a canvas, write the text in there and then convert the canvas to an image to put down my bars as I'm doing it right now already....would this be a possibility?
I know I can create like this
canvas .test -width $width -height $height -background white
but how do I convert .test into an image/photo? Can I do this at all?
Any other suggestions? Other than putting down pixels ;)
it would be more than 10 - because I need to be alphanumeric ;) that would make 36 procs then ;)

Thanks

Ron
Hours of planing can save weeks of coding
 
I have tried it like this:
Code:
set can [canvas .demo -width $width -height 50 -background red]
    $can create text 50 10 -text $number
    set im [image create photo -width $width -height $height -data $can]
but I'm getting an error Couldn't recognize image data - any clues? :eek:

Ron
Hours of planing can save weeks of coding
 
I don't think you can do it. The problem is the recognized formats for image. The only thing you can export a canvas to (at least as far as I know) is postscript. Now, if you know of a way to convert postscript to bitmap, then you're in business.

What about using a barcode font?

_________________
Bob Rashkin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top