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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Convert ntext into image

Status
Not open for further replies.

ifmo114

Programmer
Feb 27, 2002
15
US
I have a program which queries a SQL Server database and pulls back a field that's SQLServer type "ntext". I know this value represents some form of an image.

Does anyone know how to convert this into an image? Below is an example of one image's description in SQL Server...

"B!2$$$$$$$#B!G$$$";!0$$#8!O$$"!=2!Q!Q!P!0!:!Q!R!Q!@!A!R3>!@!?

The actual text is much longer.

Thanks,
JB
 
I used the Window's program called Process Explorer and it identified the file as "Assembly Source". Not sure if that helps to determine how to convert it to an image though. Any help is appreciated.
 
To read images from a database you'd need to convert the field values to a byte array. After that you can covert the bytearray to an image, providing ofcourse that the image format is supported by Java

Example:

byte[] b = null;
InputStream isr = resultset.getBinaryStream(columnNo);
ByteArrayOutputStream out = new ByteArrayOutputStream();
byte[] rb = new byte[1024];
// process blob
while ((c = isr.read(rb)) != -1) {
out.write(rb, 0, c);
}
b = out.toByteArray();
isr.close();
out.close();

BufferedImage image = ImageIO.read(new ByteArrayInputStream(b));

 
Hi Stefan,

Thanks for the info. I use the code for reading images out of a MS-Access database. I tried getBlob() before but unfortunately the standard MS-Access JDBC driver doesn't support it and throws an UnsupportedOperationException.
 
If you don't have an image identifier, you can always rename the file as a known image extension (gif, png, tiff, jpeg) and open it.

Without knowing the type of image, I think there's nothing that can be done.

Cheers,
Dian
 
Thanks for everyone's input so far. So I found out that the image type is some sort of CIC Ink Control. I'm still researching how to render this image but so far no luck. Anyone out there used this type of control before?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top