cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Try the Materials Informatics Toolkit, which is designed to easily handle SMILES data. This and other helpful add-ins are available in the JMP® Marketplace
Choose Language Hide Translation Bar
lwx228
Level VIII

How do add text to a cell that has an image loaded?

Is it possible to add text to a cell that has already loaded images?

2022-06-20_17-48-10.png

 

Thanks!

12 REPLIES 12
Craige_Hales
Super User

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 shotsMug shots

Craige
Craige_Hales
Super User

Re: How do add text to a cell that has an image loaded?

...and the orange background is because those images have transparent pixels. Your images probably don't have transparent pixels, so you probably won't see that. Preserving the transparency while adding text is a lot harder.

Craige
lwx228
Level VIII

Re: How do add text to a cell that has an image loaded?

Thanks!

I see!

2022-06-24_21-45-24.png