cancel
Showing results for 
Search instead for 
Did you mean: 

howto dispay image from binary type

Former Member
0 Kudos

Hi, I have sucesfully displayed picture from context of type "Resource" to an Image child with binded to it context of type String. I use to it belov listed piece of code and it works fine:

FileResource = value attribute if type com.sap....Resource

Image = value attribut of type String binded to Image child


if (element.getFileResource() != null) {
element.setImage(element.getFileResource().getUrl(WDFileDownloadBehaviour.OPEN_INPLACE.ordinal()));
}

Now I have encountered closely related problem (there is a smile with coding an upload as well but I was able to upload "something" != null.). I have a picture in Binary type (uploaded from mysql db). How do I display it in an Image child with String type context (you can bind other types of context to Image child than String)? Below code how I upload the image:


ResultSet rs = stUpdate2.executeQuery("SELECT * FROM photo");
	while(rs.next())
  	{
		byte[] b=rs.getBytes(1);
IWDResource res=WDResourceFactory.createCachedResource(b,"Image4",WDWebResourceType.JPG_IMAGE);				IPrivateMyProjectView.IImageTableElement imageEle=wdContext.createImageTableElement();
	imageEle.setImage3(b); //this is probably wrong, I tried bot "setImage3(res)" but I get error
//The method setImage3(byte[]) in the type IPrivateKartaPolakaView.IImageTableElement is not applicable for //the arguments (IWDResource)
//or
//imageEle.setImage3( res.getUrl(WDFileDownloadBehaviour.OPEN_INPLACE.ordinal()));
//			wdContext.nodeImageTable() .addElement(imageEle );
//how it should be but that provides me "The method setImage3(byte[]) in the type //IPrivateMyProjectView.IImageTableElement is not applicable for the arguments (String)" error
	
wdContext.nodeImageTable().addElement(imageEle );

ImageTable = Value Node

Image3 = value attribute of type binary

Please advice. Regards, Balmer.

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi

If u wnat to diasplay an image ,

1)simply take the image and copy under src->mimes>components--->urcomponentcontroller(like Comp_proj1)

2)Then take a ui element image

3)then go to the properties of image and in the source property u can write the name of image(like abc.jpg)

Regards

Hazrath

Former Member
0 Kudos

Hi,

First of all, make a string context attribute, and bind ur image UI element's source name to it.

Then write the following code:

IWDResource l_resource = WDResourceFactory.createCachedResource(<variable of type byte[] whihch has the binary type>,"MyImage",WDWebResourceType.JPG_IMAGE);

String l_image = l_resource.getUrl(WDFileDownloadBehaviour.OPEN_INPLACE.ordinal());

now set this l_image to the source context attribute.

check it out and let me know if it works.....

Regards,

Gita

SB9
Active Participant
0 Kudos

Hi,

you can use Binary-to-text encoding for this purpose. refer to the link below

[http://en.wikipedia.org/wiki/Binary-to-text_encoding]

Thanks,

S-B

Former Member
0 Kudos

that does not help me since I dont have time to write another project whuch will conver those 0.6MB binary files. There has to be simple way. Thanks anyway. Balmer