PDA

View Full Version : سوال: عدم نمایش تصویر در firefox



behnam-s
دوشنبه 19 مرداد 1388, 19:23 عصر
سلام دوستان
من با استفاده از کد زیر یک نمودار ستونی می کشم.ولی این نمودار در firefox نمایش داده نمی شه ولی در IE هیچ مشکلی نداره . راهی برای حل مشکل می دونید؟

protected void drawBarchart(Graphics g)
{
try
{
// ' Variables declaration
int i;
int xInterval = 100;
int width = 20;
int height;
SolidBrush blackBrush = new SolidBrush(Color.Black);
g.DrawString("نمودار مقایسه ای کارایی رشته "+reshte+" و حرفه "+herfe+" درسال"+year, new Font("Tahoma", 9, FontStyle.Bold), Brushes.Black, 200,15);
for (i = 0; i <= DropDownList1.Items.Count - 1; i++)
{
height = (p[i] / 20000);
//' divide by 10000 to adjust barchart to height of Bitmap

//' Draws the bar chart using specific colours
g.FillRectangle(myBrushes[i], ((xInterval * i + 150) / 4) + 10, 650 - height, width, height);

//' label the barcharts
g.DrawString(towns[i], new Font("Verdana", 8, FontStyle.Bold), Brushes.Black, ((xInterval * i + 150) / 4) + 3 + (width / 3), 650 - height - 25);

int_d_markaz_drop.SelectedIndex = i;
g.DrawString(int_d_markaz_drop.SelectedValue, new Font("Verdana", 7, FontStyle.Bold), Brushes.Black, ((xInterval * i + 150) / 4) + 5 + (width / 3), 655);

//' Draw the scale
g.DrawString(height.ToString(), new Font("Verdana", 8, FontStyle.Bold), Brushes.Black, 0, 650 - height);

//' Draw the axes
g.DrawLine(Pens.Brown, 40, 10, 40, 670);// ' y-axis
g.DrawLine(Pens.Brown, 20, 650, 950, 650);// ' x-axis
}
}
catch (Exception ex)
{
throw ex;
}
reshte = herfe = "";
}

Chabok
دوشنبه 19 مرداد 1388, 21:33 عصر
دوست عزیز .
شما باید کد کامل خود و همچنین مسیر دهی به این صفحه را قرار بدهید .

ولی اگر درست متوجه مشکل شده باشم در آدرس دهی مشکلی وجود دارد .
در وب باید آدرس شاخه ها توسط / جدا شوند .ممکن است شما مانند مسیردهی در ویندوز از شاخه ای استفاده کرده باشید و مسیر آن را توسط \ مشخص کرده اید .

مثلا به صورت زیر آدرس دهی کرده اید :
http://localhost/MyProject\MyPicture.ashx

من مشکل را در مسیر دهی می بینم .
زیرا کد سمت سرور ربطی به نمایش یا عدم نمایش آن در مرورگر ندارد .

behnam-s
سه شنبه 20 مرداد 1388, 21:54 عصر
سلام دوست من
من در Internet Explorer مشکلی با این صفحه ندارم و خوب اجرا میشه، پس فکر نمی کنم در آدرس دهی ایرادی باشه

Chabok
چهارشنبه 21 مرداد 1388, 12:47 عصر
فکر نمی کنید یا مطمئن هستید ؟

چون در IE این گونه مسیر دهی نیز تفسیر می شود . ولی در FireFox خیر .

در ضمن عرض کردم برای رفع مشکلتون کد کامل خود را قرار بدین .
موفق باشید .

behnam-s
چهارشنبه 21 مرداد 1388, 17:55 عصر
کد مسیر دهی به این صفحه:

Response.Redirect("chart1.aspx?a=" + int_d_year_txt.Text + "&b=" + int_d_reshte_drop.SelectedValue.ToString() + "&c=" + int_d_herfe_drop.SelectedValue.ToString());
در ضمن برای رسم تصویر من کد دیگه ای ندارم .همینه.و در firefox هم نه اینکه هیچی نیاره ، کل تصویر رو مثل متنی نشون می ده کدینگش مشخص نیست (اگه منظورم واضح نیست ،عکسشو بزارم)

Chabok
چهارشنبه 21 مرداد 1388, 21:59 عصر
بله . عکس رو بزارید .


در ضمن برای رسم تصویر من کد دیگه ای ندارم .

دوست عزیز . کدی که گذاشته اید ، تابعی است که یک شی Graphic می گیرد و روش نقاشی می کند .

من منظورم این است کدی که خروجی صفحه را تولید می کند اینجا قرار دهید .

کد کامل Page_Load . و مهم ترین بخش هم قسمت های ارسال به خروجی صفحه است .

قسمت هایی که به روی Response.OutputStream اطلاعات می نویسید .
و کلیه کدهایی که در این راستا عمل می کنند .

اگر هم می ترسید کسی کد شما رو ببینه و 4 تا کلمه چیز یاد بگیره بحث چیز دیگری است .

ولی اصولاً برای تولید عکس باید چنین مراحلی صورت بگیرد :

تنظیمات خروجی صفحه :

Response.BufferOutput = true;
Response.ContentType = "image/Jpeg";

نوشتن تصویر ایجاد شده بر روی خروجی :

Img.Save(ctx.Response.OutputStream, ImageFormat.Jpeg);

پایان کار

Response.End();

موفق باشید .

behnam-s
پنج شنبه 22 مرداد 1388, 01:01 صبح
این یک تابع

protected void initialiseGraphics()
{
try
{
// ' Create an in-memory bitmap where you will draw the image.
// ' The Bitmap is 300 pixels wide and 200 pixels high.
myImage = new Bitmap(950, 672, PixelFormat.Format32bppRgb);

//' Get the graphics context for the bitmap.
g = Graphics.FromImage(myImage);

//' Create the brushes for drawing
createBrushes();
}
catch (Exception ex)
{
throw ex;
}
}
protected void createBrushes()
{
int i;
try
{
myBrushes[0] = new SolidBrush(Color.Red);
myBrushes[1] = new SolidBrush(Color.Blue);
myBrushes[2] = new SolidBrush(Color.Yellow);
myBrushes[3] = new SolidBrush(Color.Green);
myBrushes[4] = new SolidBrush(Color.DarkCyan);
myBrushes[5] = new SolidBrush(Color.Red);
myBrushes[6] = new SolidBrush(Color.Blue);
myBrushes[7] = new SolidBrush(Color.Yellow);
myBrushes[8] = new SolidBrush(Color.Green);
myBrushes[9] = new SolidBrush(Color.DarkCyan);
myBrushes[10] = new SolidBrush(Color.Red);
myBrushes[11] = new SolidBrush(Color.Blue);
myBrushes[12] = new SolidBrush(Color.Red);
myBrushes[13] = new SolidBrush(Color.Blue);
myBrushes[14] = new SolidBrush(Color.Yellow);
myBrushes[15] = new SolidBrush(Color.Green);
myBrushes[16] = new SolidBrush(Color.DarkCyan);
myBrushes[17] = new SolidBrush(Color.Red);
myBrushes[18] = new SolidBrush(Color.Blue);
myBrushes[19] = new SolidBrush(Color.Yellow);
myBrushes[20] = new SolidBrush(Color.Green);
myBrushes[21] = new SolidBrush(Color.DarkCyan);
myBrushes[22] = new SolidBrush(Color.Red);
myBrushes[23] = new SolidBrush(Color.Blue);
myBrushes[24] = new SolidBrush(Color.Red);
myBrushes[25] = new SolidBrush(Color.Blue);
myBrushes[26] = new SolidBrush(Color.Yellow);
myBrushes[27] = new SolidBrush(Color.Green);
myBrushes[28] = new SolidBrush(Color.DarkCyan);
myBrushes[29] = new SolidBrush(Color.Red);
myBrushes[30] = new SolidBrush(Color.Blue);
myBrushes[31] = new SolidBrush(Color.Yellow);
myBrushes[32] = new SolidBrush(Color.Green);
myBrushes[33] = new SolidBrush(Color.DarkCyan);
myBrushes[34] = new SolidBrush(Color.Red);
myBrushes[35] = new SolidBrush(Color.Blue);
myBrushes[36] = new SolidBrush(Color.Red);
myBrushes[37] = new SolidBrush(Color.Blue);
myBrushes[38] = new SolidBrush(Color.Yellow);
myBrushes[39] = new SolidBrush(Color.Green);
}
catch (Exception ex)
{
throw ex;
}
}
و این هم فراخوانی ها

initialiseGraphics();

try
{
//' Set the background color and rendering quality.
g.Clear(Color.WhiteSmoke);

//' draws the barchart
drawBarchart(g);

//' Render the image to the HTML output stream.
myImage.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg);
}
catch (Exception ex)
{
throw ex;
}
این هم خروجی ها

IE

http://barnamenevis.org/forum/attachment.php?attachmentid=35215&stc=1&d=1250110717


FIREFOX

http://barnamenevis.org/forum/attachment.php?attachmentid=35214&stc=1&d=1250110717


دیگه قسم می خورم چیزی نیست

Chabok
پنج شنبه 22 مرداد 1388, 13:47 عصر
به نظرم این خط رو از قلم انداختین :


Response.ContentType = "image/Jpeg";همچنین چون دارید با صفحه aspx کار می کنید و ممکنه یک سری تگ های HTML در خروجی صفحه وجود داشته باشه قبل از نوشتن روی خروجی آن را خالی کنید :

یعنی در جمع کد این قسمت را به صورت زیر اصلاح کنید :


initialiseGraphics();

try
{
//' Set the background color and rendering quality.
g.Clear(Color.WhiteSmoke);

//' draws the barchart
drawBarchart(g);

Response.Clear();
Response.ContentType = "image/Jpeg";

//' Render the image to the HTML output stream.
myImage.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg);

Response.End();
}
catch (Exception ex)
{
throw ex;
}

امیدوارم که جواب بده .

behnam-s
پنج شنبه 22 مرداد 1388, 14:10 عصر
سلام
خیلی ممنونم .مشکل حل شد.