How to generate GIF iamge in ASP from web service ?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • mohit

    How to generate GIF iamge in ASP from web service ?

    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.Ge tBuffer(). 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!!2222222222 222222222222222 222222222222222 2222222222ÿÀ( ("ÿÄ 
    ÿĵ }!1A
    Qa"q2‘¡#B± ÁRÑð$3br‚
    %&'()*4567 89:CDEFGHIJSTUV WXYZcdefghijstu vwxyzƒ„…†‡ˆ‰Š'" "•–—˜™š¢£¤¥¦§¨© ª²³´µ¶·¸¹ºÂÃÄÅÆ ÇÈÉÊÒÓÔÕÖרÙÚáâ ãäåæçèéêñòóôõö÷ øùúÿÄ 
    ÿĵ w!1
    AQaq"2B‘¡ ±Á #3RðbrÑ
    $4á%ñ&'()* 56789:CDEFGHIJS TUVWXYZcdefghij stuvwxyz‚ƒ„…†‡ˆ ‰Š'""•–—˜™š¢£¤¥ ¦§¨©ª²³´µ¶·¸¹ºÂ ÃÄÅÆÇÈÉÊÒÓÔÕÖר ÙÚâãäåæçèéêòóôõ ö÷øùúÿÚ
    ?ôp2zW'© øîÒËR‚ XVæ}¢BNçù zž‹SÓ›WÒ
    ®4ô»kG›d)Çð·} §úÃÇ/¬.tÛÉ-nâhæCÈ=Çb=Aõ®zÓ "v=l·
    FµÜÝßoÔõ‹ïh¶) ½äÒ€ÐÃlf-ýÜŽÜœöãšsø–úÍÍ ÷†/­ìˆ½
    œp99Qø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¾Ðuou E2Èã£̧¸¯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="VBSCR IPT"%>
    <% Response.Expire s = 0
    Response.Buffer = True
    Response.clear
    Response.conten ttype = "image/gif"
    Response.AddHea der "content-disposition", "inline; filename=MyMap. gif"

    Set myEXE = CreateObject("E xFireSafeMapInf oTool.MapInfo")
    varGetImage = myEXE.GenerateM apForHousehold( )
    RESPONSE.Binary Write (varGetImage)

    'Value of varGetImage -- Same as Above Junk I get in ASP (Dont know
    what format is this?)
    %>

    My VB Component function is something like this -

    Public Function GenerateMapForH ousehold() 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.ClientPro perty("ServerHT TPRequest") = True
    oSOAP.MSSoapIni t "http://localhost/WebService1/GetImage.asmx?W SDL"
    bytImage = oSOAP.GetImage( "bayshore.g if")
    GenerateMapForH ousehold3A = 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
    'GenerateMapFor Household = szPicture
    'Set Form1.imgTest.P icture = LoadPicture(Gen erateMapForHous ehold)

    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.M apPath( strFileName));
    MyImage.Save(Me mStr, ImageFormat.Jpe g);
    return MemStr.GetBuffe r();
    //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
  • Auric__

    #2
    Re: How to generate GIF iamge in ASP from web service ?

    On 12 May 2004 08:33:00 -0700, mohit wrote:
    [color=blue]
    >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.Ge tBuffer(). Its an
    >array of unsigned bytes.I also tried to return it
    >in base64 encoded format.[/color]

    Learn how to crosspost. See also my response in comp.lang.basic .misc.
    --
    auric underscore underscore at hotmail dot com
    *****
    WMD? WTF!

    Comment

    Working...