当前位置: 首页 > news >正文

中南集团中南建设网站河北省住房和城乡建设厅网站首页

中南集团中南建设网站,河北省住房和城乡建设厅网站首页,龙岗建设网站,企业网站设置在SQL SERVER中建立这样结构的一个表#xff1a;列名类型目的IDInteger主键IDIMGTITLEVarchar(50)图片的标题IMGTYPEVarchar(50)图片类型. ASP.NET要以辨认的类型IMGDATAImage用于存储二进制数据 using System;using System.Collections;using System.Configuration;using…在SQL SERVER中建立这样结构的一个表列名类型目的IDInteger主键IDIMGTITLEVarchar(50)图片的标题IMGTYPEVarchar(50)图片类型. ASP.NET要以辨认的类型IMGDATAImage用于存储二进制数据       using System;using System.Collections;using System.Configuration;using System.Data;using System.Linq;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.HtmlControls;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Xml.Linq;using System.Drawing;using System.Drawing.Imaging;using System.Drawing.Drawing2D;using System.Data.SqlClient;using System.IO; public partial class ChangeImageSize : System.Web.UI.Page{    protected void Page_Load(object sender, EventArgs e)    {     }         private int width;        private int height;        private Bitmap newpic, savepic;        private float k1, k2;         /// summary        /// 构造函数        /// /summary        public ChangeImageSize()        {        }                       /// summary        /// 传入一张图片并设定它的大小        /// /summary        /// param nameTheImage传入的图片对象/param        /// param nameTheWidth图片宽的范围/param        /// param nameTheHeight图片长的范围/param        /// param namepath保存的文件名和路径/param        public Bitmap ChangePicMethod(object TheImage, int TheWidth, int TheHeight)        {            newpic new Bitmap((System.Drawing.Image)TheImage);            this.width newpic.Width;            this.height newpic.Height;             k1 (float)width / (float)TheWidth;            k2 (float)height / (float)TheHeight;            if (k1 k2)            {                this.width (int)(width / k1);                this.height (int)(height / k1);            }            else            {                this.width (int)(width / k2);                this.height (int)(height / k2);            }            savepic new Bitmap(newpic, width, height);            return savepic;            //savepic.Save(path);        }     /// summary    /// 保存图片到数据库    /// /summary    /// returns/returns        private bool StoreImage()        {            bool rs false;            Stream imgdatastream this.FileUpload1.PostedFile.InputStream;            int imgdatalen this.FileUpload1.PostedFile.ContentLength;            string imgtype this.FileUpload1.PostedFile.ContentType;            string imgtitle FileUpload1.PostedFile.FileName;            // byte[] imgdata new byte[imgdatalen];            //int n imgdatastream.Read(imgdata, 0, imgdatalen);            //Bitmap bp ChangePicToSaveMethod(imgdatastream, 200, 200);                       MemoryStream ms new MemoryStream();            Bitmap bp new Bitmap(imgdatastream);            bp ChangePicMethod(bp, 200, 200);            //bpbp.GetThumbnailImage(200,200,new System.Drawing.Image.GetThumbnailImageAbort(aa()) ,System.IntPtr.Zero);            bp.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);            ms.Flush();            byte[] imgdata ms.GetBuffer();            ms.Close();               SqlConnection connection Connection.getConnection();            SqlCommand command new SqlCommand(INSERT INTO ImageStore(ImageTitle,ImageType,ImageData)VALUES ( imgtitle, imgtype,imgdata ), connection);             SqlParameter paramTitle new SqlParameter(imgtitle, SqlDbType.VarChar, 50);             paramTitle.Value imgtitle;            command.Parameters.Add(paramTitle);             SqlParameter paramData new SqlParameter(imgdata, SqlDbType.Image);            paramData.Value imgdata;            command.Parameters.Add(paramData);             SqlParameter paramType new SqlParameter(imgtype, SqlDbType.VarChar, 50);            paramType.Value imgtype;            command.Parameters.Add(paramType);             connection.Open();            int numRowsAffected command.ExecuteNonQuery();            connection.Close();            rs true;            return rs;        }    /// summary    /// 从数据库取出图片    /// /summary    /// param namesender/param    /// param namee/param        private void GetImage(string imgid)        {            string sql SELECT ImageData, ImageType FROM ImageStore WHERE ID imgid;            SqlConnection connection Connection.getConnection();            SqlCommand command new SqlCommand(sql, connection);            connection.Open();            SqlDataReader dr command.ExecuteReader();            if (dr.Read())            {                Response.ContentType dr[ImageType].ToString();                Response.BinaryWrite((byte[])dr[ImageData]);            }            connection.Close();         }   }转载于:https://www.cnblogs.com/carekee/articles/2083425.html
http://wiki.neutronadmin.com/news/292888/

相关文章:

  • 玉环市建设局网站秦皇岛汽车网站制作
  • 免费看电视的网站有哪些坦洲网站建设公司
  • 网站建设开发价格怎么算wordpress去除acf
  • 山西省建设局网站建立一个网站需要人员
  • 访问国外网站加速响应设网站多少钱可以做
  • 做外贸主页网站用什么的空间好点做盗版网站吗
  • 前端开发专业山东济南seo整站优化公司
  • 出国看病网站开发网络营销有哪些内容
  • 网站建设联深圳推广公司网站建设书模板
  • 免费ppt模板下载公众号泰安网站建设优化技术
  • 国内产品网站1688制作灯笼图片
  • 网站开发经营范围内容管理系统开源
  • 温州建设局网站林南飞关于做数学 平方差公式的网站
  • 免费红色ppt模板网站wordpress 主题 demo
  • 南通网站建设哪家好wordpress空白页面模板
  • 宝塔面板建设网站石家庄网络推广
  • 小程序网站开发是用什么语言百度惠生活商家怎么入驻
  • 吉林房地产网站开发汕头住房和城乡建设厅网站
  • 分析竞争对手的网站wordpress 首页幻灯片
  • 网站开发w亿玛酷1专注东台建设网站
  • 备案网查询化妆品北京网络seo推广公司
  • 网站源码修复铜陵58同城做网站
  • 网站可以放多少视频高校网站开发
  • 网站空间永久免费扁平式网站
  • 宣城网站优化网站商城建设合同免费下载
  • 章丘哪里做网站网站公司 模板
  • 网站建设售前一般网站的宽度
  • 长沙哪里学网站建设wordpress 清理缩略图
  • 最大的网站模板网wordpress增加内链
  • 电子商务网站开发模块流程图建网站 赚钱