cancel
Showing results for 
Search instead for 
Did you mean: 

how to display image in Image UI element from byte array

Former Member
0 Kudos

Hi,

How to display image in Image UI element from byte array.

Regards,

H.V.Swathi

Accepted Solutions (0)

Answers (2)

Answers (2)

srinivas_sistu
Active Contributor
0 Kudos

Hi,

If you have a byte array, then create a resource from it then get the url of the resource and set this value with image UI's Resource Property. Some thing like this...

IWDResource webResource = null;

ByteArrayOutputStream bOut=new ByteArrayOutputStream();

now get the image into this bOut

webResource=rsf.createCachedResource(bOut.toByteArray(),"My Test",WDWebResourceType.JPG_IMAGE);

after this generate an URL for this resource and map it with image UI's Resource Property Say Va_Resouce

wdContext.CurrentContextElement().setVa_Resouce(webResource.getUrl(WDFileDownloadBehaviour.OPEN_INPLACE.ordinal()));

Thats it... you are done....

Regards,

SrinivaS

Former Member
0 Kudos

Hi,

Thanks for ur reply.

But i take that image in the form of byte [] from database.

byte[]	bOut=wdContext.currentWaElement().getEmp_Image();

		webResource=WDResourceFactory.createCachedResource(bOut,"My Test",WDWebResourceType.JPG_IMAGE);

		wdContext.currentResourcesElement().setUploadImgResource(webResource);
		wdContext.currentResourcesElement().setUploadImgURL(webResource.getUrl(WDFileDownloadBehaviour.OPEN_INPLACE.ordinal())	);

Regards,

H.V.Swathi

Edited by: H.V Swathi on Jun 11, 2009 2:12 PM

srinivas_sistu
Active Contributor
0 Kudos

Hi,

find this below code...

byte[] imagebyte = null;

InputStream in=null;

try {

con=condb.getConnection (mgnr);

stmnt=con.createStatement();

rs=stmnt.executeQuery("select * from VMS_Image");

//Pass_No,name,Image

while(rs.next())

{

mgnr.reportSuccess("Name :"+rs.getString("name"));

imagebyte=rs.getBytes("Image");

in=rs.getBinaryStream("Image");

mgnr.reportSuccess("Image>>"+imagebyte);

ByteArrayOutputStream bOut=new ByteArrayOutputStream();

int lenght=0;

byte part[]=new byte[10*1024];

while((lenght=in.read(part))!=-1)

{

bOut.write(part,0,lenght);

}

in.close();

after this use the code which i gave earlier...

Regards,

SrinivaS

Former Member
0 Kudos

HI,

Thank you.

I am taking this image byte array from R3 table through function module.

Regards,

H.V.Swathi

Former Member
0 Kudos

Hi Swathi,

Check this blog:

/people/anilkumar.vippagunta2/blog/2007/02/20/reading-and-writing-images-from-sqlserver-in-webdynpro

Also this thread:

Hope this helps!!

Regards,

Jaya.