Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/210.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sql-server/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android:从MSSQL检索图像_Android_Sql Server_Database_Bitmap_Bitmapfactory - Fatal编程技术网

Android:从MSSQL检索图像

Android:从MSSQL检索图像,android,sql-server,database,bitmap,bitmapfactory,Android,Sql Server,Database,Bitmap,Bitmapfactory,我是Android新手,尝试从MSSQL获取图像并将其设置为背景 CallableStatement proc = null; String temp2 ="{ call AndroidDB.dbo.getStocks("+ temp +")}"; proc = MainActivity.conn.prepareCall(temp2);

我是Android新手,尝试从MSSQL获取图像并将其设置为背景

                 CallableStatement proc = null;                 
                 String temp2 ="{ call AndroidDB.dbo.getStocks("+ temp +")}";
                 proc = MainActivity.conn.prepareCall(temp2);
                 ResultSet rs = proc.executeQuery();
                 Bitmap bitmap= null;
                 byte[] blob =null;
                 for (int i = 0,j=0; rs.next(); i++ ) {
                    if(i%3==0){
                        layout_stocks_h.add(new LinearLayout(this));
                        (layout_stocks_h.get(j)).setOrientation(LinearLayout.HORIZONTAL);
                        LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); // Verbose!
                        lp.weight = 1.0f;
                        (layout_stocks_h.get(j)).setLayoutParams(lp);
                        layout_stocks_v.addView((layout_stocks_h.get(j)));
                        (layout_stocks_h.get(j)).setId(200+(j));
                        j++;                    
                }
                imagebutton_stocks.add(new ImageButton(this));

                blob = rs.getBytes("stokresim");
                ByteArrayInputStream imageStream = new ByteArrayInputStream(blob);
                bitmap = BitmapFactory.decodeStream(imageStream);
                imagebutton_stocks.get(i).setImageBitmap(bitmap);

                imagebutton_stocks.get(i).setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT));
                layout_stocks_h.get(j-1).addView(imagebutton_stocks.get(i));
                imagebutton_stocks.get(i).setId(250+i);
                imagebutton_stocks.get(i).setOnClickListener(this);
                noOfStocks = i;
我还尝试使用:

bitmap =  BitmapFactory.decodeByteArray(blob , 0, blob.length);
但是,没有任何效果,我的过程工作正常,创建了正确数量的按钮,但没有图像

我将图像文件作为图像存储在MSSQL中,并尝试使用varbinary(MAX)


提前感谢

我还尝试使用二进制流blob=rs.getBinaryStream(“stokresim”);位图=BitmapFactory.decodeStream(blob);但没有起作用:(