I am struggling for long time to display a GIF file on an ASP page. I have tried to return a GIF file in few formats
from a webservice.
Webservice returns the images as MemoryStream.GetBuffer(). Its an array of unsigned bytes.I also tried to return it
in base64 encoded format.
I can call this webservice in either of 2 ways
1) Directly from ASP -- It returns me this ..
ÿØÿàJFIF``ÿÛC $.' ",#(7),01444'9=82<.342ÿÛC 2!!22222222222222222222222222222222222222222222222222ÿÀ(("ÿÄ ÿĵ}!1A
Qa"q2‘¡#B±ÁRÑð$3br‚ %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyzƒ„…†‡ˆ‰Š’“”•–—˜™š¢£¤¥¦§¨©ª²³´µ¶·¸¹ºÂÃÄÅÆÇÈÉÊÒÓÔÕÖרÙÚáâãäåæçèéêñòóôõö÷øùúÿÄ ÿĵw!1
AQaq"2B‘¡±Á #3RðbrÑ $4á%ñ&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz‚ƒ„…†‡ˆ‰Š’“”•–—˜™š¢£¤¥¦§¨©ª²³´µ¶·¸¹ºÂÃÄÅÆÇÈÉÊÒÓÔÕÖרÙÚâãäåæçèéêòóôõö÷øùúÿÚ ?ôp2zW'©øîÒËR‚ XVæ}¢BNî«çùzž‹SÓ›WÒ
®4ô»kG›d)Çð·}§úÃÇ/¬.tÛÉ-nâhæCÈ=Çb=Aõ®zÓ”v=l· FµÜÝßoÔõ‹ïh¶)½äÒ€ÐÃlf-ýÜŽÜœöãšsø–úÍÍ÷†/숽 œp99Qøf¹Ï‡ú…•½ôösÀ¿j¹[ÍŒ{§¶G§qŽõéò¬[<Å„hó '•>Æœ¦¯r1èágìÜ/æßåbµÌW–Ý@áá™w#Û§>‡Ž”Vƒv¦ª[#“
µû, Oðsÿ ¯çEk sFç"’¥UÁlŽ’$JˆI˜@Î?õÄÇ£Çã+ÍsT™Þ8’e¶´ ç`ã#¾Gç]´D ³m†O¥s> ;4ÛÍ4¡v—R4ÉŽ@ ãÓ*J‰¤ä“:0³•:U*CuoÌó½KK¾ÐuouE2Èã£Ì§¸¯R±ñ#Iá3â ”òf‰
2) From VB(again I am returning byte array) which inturn is called by ASP -- I get the
same junk as above.
I need to convert it as a GIF file in my ASP page.
Can you guys suggest how it could by achived. I am open to change code at any layer.
Note - I am not getting any file back from VB or Web service. I am only getting it in some encoded format(byte array
or base64)
My ASP code is like this -
<%@ LANGUAGE="VBSCRIPT"%>
<% Response.Expires = 0
Response.Buffer = True
Response.clear
Response.contenttype = "image/gif"
Response.AddHeader "content-disposition", "inline; filename=MyMap.gif"
Set myEXE = CreateObject("ExFireSafeMapInfoTool.MapInfo")
varGetImage = myEXE.GenerateMapForHousehold()
RESPONSE.BinaryWrite (varGetImage)
'Value of varGetImage -- Dont know what format is this?
ÿØÿàJFIF``ÿÛC $.' ",#(7),01444'9=82<.342ÿÛC 2!!22222222222222222222222222222222222222222222222222ÿÀ(("ÿÄ ÿĵ}!1A
Qa"q2‘¡#B±ÁRÑð$3br‚ %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyzƒ„…†‡ˆ‰Š’“”•–—˜™š¢£¤¥¦§¨©ª²³´µ¶·¸¹ºÂÃÄÅÆÇÈÉÊÒÓÔÕÖרÙÚáâãäåæçèéêñòóôõö÷øùúÿÄ ÿĵw!1
AQaq"2B‘¡±Á #3RðbrÑ $4á%ñ&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz‚ƒ„…†‡ˆ‰Š’“”•–—˜™š¢£¤¥¦§¨©ª²³´µ¶·¸¹ºÂÃÄÅÆÇÈÉÊÒÓÔÕÖרÙÚâãäåæçèéêòóôõö÷øùúÿÚ ?ôp2zW'©øîÒËR‚ XVæ}¢BNî«çùzž‹SÓ›WÒ
®4ô»kG›d)Çð·}§úÃÇ/¬.tÛÉ-nâhæCÈ=Çb=Aõ®zÓ”v=l· FµÜÝßoÔõ‹ïh¶)½äÒ€ÐÃlf-ýÜŽÜœöãšsø–úÍÍ÷†/숽 œp99Qøf¹Ï‡ú…•½ôösÀ¿j¹[ÍŒ{§¶G§qŽõéò¬[<Å„hó '•>Æœ¦¯r1èágìÜ/æßåbµÌW–Ý@áá™w#Û§>‡Ž”Vƒv¦ª[#“
µû, Oðsÿ ¯çEk sFç"’¥UÁlŽ’$JˆI˜@Î?õÄÇ£Çã+ÍsT™Þ8’e¶´ ç`ã#¾Gç]´D ³m†O¥s> ;4ÛÍ4¡v—R4ÉŽ@ ãÓ*J‰¤ä“:0³•:U*CuoÌó½KK¾ÐuouE2Èã£Ì§¸¯R±ñ#Iá3â ”òf‰
%>
My VB Component function is something like this -
Public Function GenerateMapForHousehold() As Variant
Dim szFileName As String
Dim oSOAP As New SoapClient30 'Soap Type Library 3
Dim bytImage() As Byte
Dim szPicture As String
Dim iCount As Integer
Dim File As Integer
File = FreeFile
'Make the Call to Web Service to retrive the Image.
oSOAP.ClientProperty("ServerHTTPRequest") = True
oSOAP.MSSoapInit "http://localhost/WebService1/GetImage.asmx?WSDL"
bytImage = oSOAP.GetImage("bayshore.gif")
GenerateMapForHousehold3A = bytImage
'I can retreive this image in VB using this code -
'szPicture = App.Path & "\Test.gif"
'Open szPicture For Binary As File
'For iCount = LBound(bytImage) To UBound(bytImage) - 1
' Put #1, , bytImage(iCount)
'Next
'Close #1
'GenerateMapForHousehold = szPicture
'Set Form1.imgTest.Picture = LoadPicture(GenerateMapForHousehold)
End function
And web service(c#) method is something like this-
using System.IO;
using System.Drawing.Imaging;
public byte[] GetImage(string strFileName)
{
StreamWriter sr;
Byte sIn = new Byte();
Image MyImage;
MemoryStream MemStr = new MemoryStream();
MyImage = new Bitmap(Server.MapPath( strFileName));
MyImage.Save(MemStr, ImageFormat.Jpeg);
return MemStr.GetBuffer();
//I have 1 more function to return base64 encoded string but dont know how to use it further.
}
Please help.
Thanks
Mohit
e mail - mohitFL@hotmail.com