再加100分,求解

阿达King哥 2007-05-20 05:28:58
http://community.csdn.net/Expert/topic/5547/5547176.xml?temp=.6938593
...全文
174 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
yixianggao 2007-05-20
  • 打赏
  • 举报
回复
找到了,Employee 的 photo 里保存的是 gif 格式,因此 有 78 的偏移量!

Pub 库就没这事儿!

// 78 is the size of the OLE header
// for Northwind images.
// There's no header in PUBS as PUBS
// just contains the raw image bits.
int offset = 78;

详见!
http://www.ftponline.com/vsm/2002_07/online/hottips/esposito/


俺试了试,可以看到!

ImageReader.aspx.cs

// 改成雇员 Id 就可以了
string pubId = Request.QueryString["pubId"];
byte[] byteImage = PublishiersProcessor.GetLogoByPubId(pubId);

MemoryStream ms = new MemoryStream();
// 78 is the size of the OLE header
// for Northwind images.
// There's no header in PUBS as PUBS
// just contains the raw image bits.
int offset = 78;
ms.Write(byteImage, offset, byteImage.Length - offset);

Bitmap bmp = new Bitmap(ms);

Response.ContentType = "image/gif";

bmp.Save(Response.OutputStream, ImageFormat.Gif);
ms.Close();
yixianggao 2007-05-20
  • 打赏
  • 举报
回复
忘了说了,pub_info 是 pubs 库的,但字段类型一致!
yixianggao 2007-05-20
  • 打赏
  • 举报
回复
俺读的是 pub_info 的 logo 图像,应该没区别,从下往上依次调用代码如下:


数据访问层

/// <summary>
/// 根据 出版社 Id 选择 Logo 图像。
/// </summary>
/// <param name="pubId">出版社 Id。</param>
/// <returns>Logo 图像字节数组。</returns>
public static byte[] SelectLogoByPubId(string pubId)
{
string sqlText = @"
SELECT
logo
FROM
pub_info
WHERE
pub_id = @pub_id
";
SqlParameter[] commandParameters = new SqlParameter[1];
commandParameters[0] = new SqlParameter("@pub_id", pubId);

return (byte[])SqlHelper.ExecuteScalar(WebConfigReader.LocalPubs, sqlText, commandParameters);
}


ImageReader.aspx.cs

public partial class ImageReader : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string pubId = Request.QueryString["pubId"];
Response.ContentType = "image/jpeg";
byte[] byteImage = PublishiersProcessor.GetLogoByPubId(pubId);
Response.OutputStream.Write(byteImage, 0, byteImage.Length);
Response.End();
}
}

BookInfoListByPublisher.aspx.cs

// 读取出版社 Logo
this.imgPublisherLogo.Visible = true;
this.imgPublisherLogo.ImageUrl = string.Format("~/ImageReader.aspx?pubId={0}", PubId);
emenwin 2007-05-20
  • 打赏
  • 举报
回复
学习
阿达King哥 2007-05-20
  • 打赏
  • 举报
回复
楼上,你的做法的原理跟我的有区别吗?
最后一只恐龙 2007-05-20
  • 打赏
  • 举报
回复
web上画图不是这么画的,下面文章2.2部分,我blog上的:
http://blog.csdn.net/Ivy_zheng/archive/2007/03/23/1538170.aspx

62,046

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧