- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
How do add text to a cell that has an image loaded?
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: How do add text to a cell that has an image loaded?
Use a graphics frame box to add text and lines on top of a picture.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: How do add text to a cell that has an image loaded?
dt = Open( "$SAMPLE_DATA/Big Class Families.jmp" );
For( iRow = 1, iRow <= N Rows( dt ), irow += 1,
// open the original
original = dt:picture[iRow];
{xSize, ySize} = original << size;
// use a frame to do the drawing, make the original fit the frame exactly
gb = Graph Box(
<<backgroundcolor( "orange" ), // to see errors better
FrameSize( xSize + 1, ySize + 1 ), // the +1 is required, 4 times
X Scale( 0, xSize + 1 ),
Y Scale( 0, ySize + 1 ),
// apparently x and y are different. this is correct in 17EA.
<<Add Image( image( original ), bounds( top( 0 ), Left( 1 ), bottom( ySize ), Right( xSize + 1 ) ) ),
// draw something on top of the image
Text( Center Justified, {xSize / 2, 10}, dt:name[irow] );
);
// capture an updated image
updated = gb[framebox( 1 )] << getpicture;
// crop added border. "updated" is the final image.
updated << crop( Left( 1 ), top( 1 ), Right( xSize + 1 ), bottom( ySize + 1 ) );
dt:picture[irow]=updated;
);
Mug shots
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: How do add text to a cell that has an image loaded?
You could use set each value to re-create the image with text
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class Families.jmp");
Column(dt, "picture") << Set Each Value(
H List Box(align("center"),
Text box(:name),
:picture
) << Get Picture
);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: How do add text to a cell that has an image loaded?
If I want to add more than one cell of text, I try to add it left and right.
Can I add text below?It looks like this down here.
Column(dt, "picture") << Set Each Value(
H List Box(align("center"),
Text box(:name),
:picture
) << Get Picture
);
Column(dt, "picture") << Set Each Value(
H List Box(align("center"),
Text box(:sports),
:picture
) << Get Picture
);
Thanks Experts!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: How do add text to a cell that has an image loaded?
Using proper display functions (h list box, v list box, lineup box...) and display boxes should help you to organize the elements
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: How do add text to a cell that has an image loaded?
JSL can add text to a screenshot and then place it on the image.
Thanks!
dt = Open( "$SAMPLE_DATA/Big Class Families.jmp" );
rp = New Window( "", dt << Get As Report );
rp << Set Cell Height( 250 );
pic = rp << Get Picture;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: How do add text to a cell that has an image loaded?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: How do add text to a cell that has an image loaded?
Thank Craige!
I copied the following JSL, just to achieve the simplest function.
But I still don't know the code.Text is not added where it should be.
Consult experts to help modify, with the simplest code implementation.
Thanks Experts!
dt = Open( "$SAMPLE_DATA/Big Class Families.jmp" );
dt << delete columns( 3 :: N Col( dt ) );
dt << delete rows( 6 :: N Row( dt ) );
dt << Set Cell Height( 100 );
rp = New Window( "", dt << Get As Report );
original = rp << Get Picture;
{xSize, ySize} = original << size;
gb = Graph Box(
<<backgroundcolor( "orange" ),
FrameSize( xSize + 1, ySize + 1 ),
X Scale( 0, xSize + 1 ),
Y Scale( 0, ySize + 1 ),
<<Add Image( image( original ), bounds( top( 0 ), Left( 1 ), bottom( ySize ), Right( xSize + 1 ) ) ),
Text( Center Justified, { 50, 10}, "KATIE" )
);
updated = gb[framebox( 1 )] << getpicture;
updated << crop( Left( 1 ), top( 1 ), Right( xSize + 1 ), bottom( ySize + 1 ) );
originalMatrix = original << getpixels;
newMatrix = updated << getpixels;
diff = (originalMatrix - newMatrix != 0);
New Window( "bitmaps", V List Box( gb ) );
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: How do add text to a cell that has an image loaded?
Text( Center Justified, { 50, 10}, "KATIE" )
How can this code be modified to fit inside the original image?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: How do add text to a cell that has an image loaded?
text size function; 5 points is a little too small for my eyes.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: How do add text to a cell that has an image loaded?
Wait. You are using a picture of the whole data table, but I'm pretty sure you want to work on one picture at a time.
Just grab the image from dt:picture[iRow] rather than loading it from a file, then replace it when done. Approximately like this:
original = dt:picture[iRow];
...existing jsl...
dt:picture[iRow] = updated;