2
Answers

how to set width equally for an image or place it center c#

prabha haran

prabha haran

8y
283
1
hi
 how to add an white space around my reflected image using c#
private static System.Drawing.Image DrawReflection(System.Drawing.Image img, Color toBG, int _Reflectivity) // img is the original image.
{
//This is the static function that generates the reflection...
//int height = img.Height + 100; //Added height from the original height of the image.
// Calculate the size of the new image
int height = (int)(img.Height + (img.Height * ((float)_Reflectivity / 450)));
int Width = (int)(img.Width + (img.Width * ((float)_Reflectivity / 250)));


Bitmap bmp = new Bitmap(Width, height, PixelFormat.Format24bppRgb);


bmp.SetResolution(img.HorizontalResolution, img.VerticalResolution);

//Bitmap bmp = new Bitmap(img.Width, height, PixelFormat.Format64bppPArgb); //A new bitmap.
//Brush brsh = new LinearGradientBrush(new Rectangle(0, 0, img.Width + 10, height), Color.Transparent, toBG, LinearGradientMode.Vertical);//The Brush that generates the fading effect to a specific color of your background.
//bmp.SetResolution(img.HorizontalResolution, img.VerticalResolution); //Sets the new bitmap's resolution.
using (Graphics grfx = Graphics.FromImage(bmp)) //A graphics to be generated from an image (here, the new Bitmap we've created (bmp)).
{
// Initialize main graphics buffer
grfx.Clear(toBG);
grfx.DrawImage(img, new Point(0, 0));
grfx.InterpolationMode = InterpolationMode.HighQualityBicubic;
Rectangle destinationRectangle = new Rectangle(0, img.Size.Height,
img.Width, img.Size.Height);

// Prepare the reflected image
int reflectionHeight = (img.Height * _Reflectivity) / 450;
//int refwidth = (Width / 50);
System.Drawing.Image reflectedImage = new Bitmap(img.Width, reflectionHeight);

// Draw just the reflection on a second graphics buffer
using (Graphics gReflection = Graphics.FromImage(reflectedImage))
{
gReflection.DrawImage(img,
new Rectangle(0,0, reflectedImage.Width, reflectedImage.Height),
0, img.Height - reflectedImage.Height, reflectedImage.Width,
reflectedImage.Height, GraphicsUnit.Pixel);
}
reflectedImage.RotateFlip(RotateFlipType.RotateNoneFlipY);
Rectangle imageRectangle =
new Rectangle(destinationRectangle.X, destinationRectangle.Y,
destinationRectangle.Width,
(destinationRectangle.Height * _Reflectivity) / 450);

// Draw the image on the original graphics
grfx.DrawImage(reflectedImage, imageRectangle);

// Finish the reflection using a gradiend brush
LinearGradientBrush brush = new LinearGradientBrush(imageRectangle,
Color.FromArgb(255 - _Reflectivity, toBG),
toBG, 90, false);
grfx.FillRectangle(brush, imageRectangle);
}
return bmp; //Returns the (bmp) with the generated image.
}
 
 
and my output is
Answers (2)
0
Suthish Nair
NA 31.7k 4.6m 14y
If your query got resolved, then accept the post that helped you as Answer.
0
Suthish Nair
NA 31.7k 4.6m 14y
attach your both pages..
0
Madhu K
NA 2k 446k 14y
The name 'ContractId' does not exist in the current context

Clearly tells that ContractId isn't declared as string. and from your code I observed that you did not used the query string anywhere else. Anyhow just declare ContractId as string.


string ContractId = Request.QueryString["ContractId"].ToString();


0
Amit Choudhary
NA 27.7k 3m 14y
Hi becky,

Everything seems to be fine in Code ... Try Rebuild your solution to get the fresh assemblies of updated code.


0
Becky Bloomwood
NA 119 240.2k 14y

I added in he code thatyou gave me, but there is still error:

protected void Page_Load(object sender, EventArgs e)
{
//string strContractId = Request.QueryString["ContractId"].ToString();
//string cid = Convert.ToString(Request.QueryString["ContractId"]);
//if (cid != null)
//{
// Response.Write("Fetch Records on the basis of ContracID " + cid);
//}
if(Request.QueryString["ContractId"]!=null)
{
ContractId = Request.QueryString[
"ContractId"].ToString();
}



if (!IsPostBack)
{
//Set the sortExpression
ViewState[
this.ToString() + "_SortExpression1"] = "Terms";
ViewState[
this.ToString() + "_SortDirection1"] = "ASC";
//Set the sortExpression
ViewState[
this.ToString() + "_SortExpression2"] = "FileName";
ViewState[
this.ToString() + "_SortDirection2"] = "ASC";
//Set the sortExpression
ViewState[
this.ToString() + "_SortExpression3"] = "Item";
ViewState[
this.ToString() + "_SortDirection3"] = "ASC";



//populate the criticalterms datatable
DataTable tmpdt = vrmdb.Get_CriticalTerms().Tables[0];
//tmpdt = new DataTable();
tmpdt.PrimaryKey =
new DataColumn[] { tmpdt.Columns[0] };
ViewState[viewStateGVName] = tmpdt;

//populate the uploadeddocuments datatable
DataTable tmpdtt = vrmdb.Get_UploadedDocuments().Tables[0];
tmpdtt =
new DataTable();
tmpdtt = vrmdb.Get_UploadedDocuments().Tables[0];
tmpdtt.PrimaryKey =
new DataColumn[] { tmpdtt.Columns[0] };
ViewState[viewStateGVUDName] = tmpdtt;
//populate the uploadeddocuments datatable
DataTable tmpCdt = vrmdb.Get_Checklist().Tables[0];
tmpCdt =
new DataTable();
tmpCdt = vrmdb.Get_Checklist().Tables[0];
tmpCdt.PrimaryKey =
new DataColumn[] { tmpCdt.Columns[0] };
ViewState[viewStateGVCLName] = tmpCdt;



BindGrid();
BindGrid1();
BindGrid2();
//string strContractId = Request.QueryString["ContractId"].ToString();


}
}
This is the error:

Server Error in '/VRM_WebSite' Application.

Compilation Error


Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS0103: The name 'ContractId' does not exist in the current context

Source Error:

Line 36:              if(Request.QueryString["ContractId"]!=null)
Line 37:                 {
Line 38:                     ContractId = Request.QueryString["ContractId"].ToString();
Line 39:                 }
Line 40: 

Source File: c:\Users\L31410\Desktop\Peggie\Peggie\Deployment Source\Phase 1\Deployment 25 Nov for StarHub\VS Projects Source\VRM_WebSite\app\vrm\ContractThreeGridView.aspx.cs    Line: 38




 




Version Information: Microsoft .NET Framework Version:2.0.50727.4952; ASP.NET Version:2.0.50727.4955
Thanks!
0
Madhu K
NA 2k 446k 14y
By using following code you can get rid of the error.
If(Request.QueryString["ContractId"]!=null)
{
strContractId = Request.QueryString["ContractId"].ToString();
}

Use the debugger place a breakpoint and check whether you are getting the value from
from the query string or not.