當我的圖像是空的時,IE將它繪製爲紅色十字。有什麼辦法可以避免畫紅十字?IE空圖像=紅色十字: -/
或因爲我有asp圖片我可以使它不可見,但是然後我需要檢查這個圖像是否包含一些東西。
<asp:Image ID="Image1" runat="server" ImageUrl="Handler.ashx"/>
我需要加載到byte [] x = {??? };一個白色像素在圖像/ jpeg格式
我的解決方案讓我瘋狂! 這裏是:
<%@ WebHandler Language="C#" Class="Handler" %>
using System;
using System.IO;
using System.Web;
using Auth;
using System.Configuration;
public class Handler : IHttpHandler
{
public bool IsReusable
{ get{ return false; } }
public void ProcessRequest(HttpContext context)
{
context.Response.Clear();
context.Response.ContentType = "image/jpeg";
byte[] imageContent = Auth.User.GetImageFromDataBase();
if (imageContent != null)
context.Response.OutputStream.Write(imageContent, 0, imageContent.Length);
else
{
byte[] x = {0xff, 0xd8, 0xff, 0xe0, 0x0, 0x10, 0x4a, 0x46, 0x49, 0x46, 0x0, 0x1, 0x2, 0x0, 0x0, 0x64,
0x0, 0x64, 0x0, 0x0, 0xff, 0xec, 0x0, 0x11, 0x44, 0x75, 0x63, 0x6b, 0x79, 0x0, 0x1, 0x0,
0x4, 0x0, 0x0, 0x0, 0x1b, 0x0, 0x0, 0xff, 0xee, 0x0, 0xe, 0x41, 0x64, 0x6f, 0x62, 0x65,
0x0, 0x64, 0xc0, 0x0, 0x0, 0x0, 0x1, 0xff, 0xdb, 0x0, 0x84, 0x0, 0x11, 0xc, 0xc, 0xc,
0xd, 0xc, 0x11, 0xd, 0xd, 0x11, 0x19, 0x10, 0xe, 0x10, 0x19, 0x1d, 0x16, 0x11, 0x11, 0x16,
0x1d, 0x22, 0x17, 0x17, 0x17, 0x17, 0x17, 0x22, 0x21, 0x1a, 0x1d, 0x1c, 0x1c, 0x1d, 0x1a, 0x21,
0x21, 0x26, 0x28, 0x2b, 0x28, 0x26, 0x21, 0x34, 0x34, 0x38, 0x38, 0x34, 0x34, 0x41, 0x41, 0x41,
0x41, 0x41, 0x41, 0x41, 0x41, 0x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2, 0x86, 0x39, 0x13, 0xb1, 0xe8, 0xc4, 0x57, 0x27, 0x72, 0xae, 0x55, 0x0, 0xa1,
0xe0, 0x14, 0xae, 0x57, 0xad, 0x72, 0xcd, 0x98, 0x5d, 0xb, 0x2d, 0x48, 0xd7, 0x44, 0x8f, 0xe8,
0xaa, 0x89, 0xab, 0x2b, 0x85, 0xeb, 0x8f, 0x58, 0xd7, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x7, 0xff, 0xd9};
context.Response.OutputStream.Write(x, 0, x.Length);
}
}
}
在這裏也搜索「破碎的圖像」,這會給你一些替代選項。 – Lazarus 2010-02-03 11:13:47
@Lazarus你是什麼意思? 。 。 。 – Cynede 2010-02-03 11:39:58
使用本頁頂部的搜索字段來搜索「破碎的圖像」,您將看到與您遇到的相同問題相關的所有問題和答案,例如,指向不再存在或已存在圖像的img標籤已被移動。 – Lazarus 2010-02-03 12:06:32