1

画像データ型はSybaseでバイト配列に変換されますか?Webサービスを適用してsybase(画像データ型)のデータセットを取得します。byte[]を使用してWebサービスを返します。次に、「response.binarywrite(byte [])」を使用して画像を表示します。(ASP.NETC#)しかし、画像の歪みの問題があります(画像をズームすると、いくつかのポイントが失われます)。なぜsybaseの画像データ型をバイト配列に転送できることを誰かが知っているのかわかりませんか?

元の画像

歪み画像

システム:

1 Sybase

    Sybase db: 11.9.2

    Adaptive server enterprise 12.5.1

    Sybase.Data.AseClient:1.0.152.0

2 ASP.NET C#(Visual Studio 2008)

3 IE6

4

1 に答える 1

4

最後に、私はアンサーを見つけます。この問題の理由は、Sybase でのイメージのサイズへのアクセスの制限です。画像のサイズが 37k バイトを超える場合でも、出力は 37K のままです。したがって、このステップで一部のバイトが欠落しています。解決策は、すべてのデータを取得するようにパラメーターを設定する必要があることです。部分的なコードは次のとおりです。

    [WebMethod]
    public byte[] Image(string c, string r)
    {
       //check input ..
        ConnectionDatabase connbaseloc = new ConnectionDatabase();
        AseConnection conn1 = null;
        AseCommand cmd1 = null;
        string sqlstr1 = "";
        AseDataReader reader = null;
        byte[] Imagebytes = null;
        try
        {
            using (conn1 = connbaseloc.Odbcconn_xxx())
            {
                string setTextCmd = " SET TEXTSIZE 130000"; //set parameter
                cmd1 = new AseCommand(setTextCmd, conn1);
                cmd1.ExecuteNonQuery();
                sqlstr1 = "select ....";
                cmd1 = new AseCommand(sqlstr1, conn1);
                cmd1.CommandText = sqlstr1;
                reader = cmd1.ExecuteReader();
                while (reader.Read())
                {
                    Imagebytes = (byte[])reader["Image"];
                }
            }
        }
        catch (Exception e)
        {
            //do something
        }
        finally
        {
            if (conn1 != null) conn1.Close();
        }

        return Imagebytes;
    }

パラメータ値は、画像の最大サイズによって異なります。

于 2009-12-15T08:50:51.150 に答える