hi all,

i am writing my own messagebox control, it's composed of 3 parts
1) Top bar
2) Middle Area (resizable)
3) Buttom bar

the top and bottom bar sizes doesn't change, but the middle area
changes depending on the size of the dialogbox (im my case a form that
i resize). When i draw the middle image it moves 1 pixel to the right
and goes 1 pixel out of the display bounds... i don't know why, here's
what i am doing

protected override void OnPaint(PaintEventArgs e)
{
gxBuffer.DrawImage(topBar, 0, 0);
gxBuffer.DrawImage(middleArea,new Rectangle(0,this.Location
+topBar.Height,this.Width,this.Height),new
Rectangle(0,0,this.middleArea.Width,this.middleArea.Height),
GraphicsUnit.Pixel);
gxBuffer.DrawImage(buttomBar, 0, this.Location.Y -
buttomBar.Height);
e.Graphics.DrawImage(offScreen, 0, 0);
}

although when i place the middleArea image in a picturebox and stretch
it, it works well....
any pointers would be really apreciated

Thanks

Re: Image Strectch using Graphics.DrawImage() by Jin

Jin
Fri Jan 18 10:58:26 CST 2008

On Jan 18, 11:40 am, mrabie <mustafa.ra...@gmail.com> wrote:
> hi all,
>
> i am writing my own messagebox control, it's composed of 3 parts
> 1) Top bar
> 2) Middle Area (resizable)
> 3) Buttom bar
>
> the top and bottom bar sizes doesn't change, but the middle area
> changes depending on the size of the dialogbox (im my case a form that
> i resize). When i draw the middle image it moves 1 pixel to the right
> and goes 1 pixel out of the display bounds... i don't know why, here's
> what i am doing
>
> protected override void OnPaint(PaintEventArgs e)
> {
> gxBuffer.DrawImage(topBar, 0, 0);
> gxBuffer.DrawImage(middleArea,new Rectangle(0,this.Location
> +topBar.Height,this.Width,this.Height),new
> Rectangle(0,0,this.middleArea.Width,this.middleArea.Height),
> GraphicsUnit.Pixel);
> gxBuffer.DrawImage(buttomBar, 0, this.Location.Y -
> buttomBar.Height);
> e.Graphics.DrawImage(offScreen, 0, 0);
> }
>
> although when i place the middleArea image in a picturebox and stretch
> it, it works well....
> any pointers would be really apreciated
>
> Thanks

Not really sure without seeing the rest of your code, but it could be
related to:

this.Location+topBar.Height

because this.Location is a Point. I haven't tested what result is
returned when you do this (perhaps increment both X and Y values?).

- Jin

Re: Image Strectch using Graphics.DrawImage() by mrabie

mrabie
Fri Jan 18 13:06:35 CST 2008

On Jan 18, 8:58=A0am, Jin Chang <jinsooch...@gmail.com> wrote:
> On Jan 18, 11:40 am, mrabie <mustafa.ra...@gmail.com> wrote:
>
>
>
>
>
> > hi all,
>
> > i am writing my own messagebox control, it's composed of 3 parts
> > 1) Top bar
> > 2) Middle Area (resizable)
> > 3) Buttom bar
>
> > the top and bottom bar sizes doesn't change, but the middle area
> > changes depending on the size of the dialogbox (im my case a form that
> > i resize). =A0When i draw the middle image it moves 1 pixel to the right=

> > and goes 1 pixel out of the display bounds... i don't know why, here's
> > what i am doing
>
> > protected override void OnPaint(PaintEventArgs e)
> > =A0 =A0 =A0 =A0 {
> > =A0 =A0 =A0 =A0 =A0 =A0 gxBuffer.DrawImage(topBar, 0, 0);
> > =A0 =A0 =A0 =A0 =A0 =A0 gxBuffer.DrawImage(middleArea,new Rectangle(0,th=
is.Location
> > +topBar.Height,this.Width,this.Height),new
> > Rectangle(0,0,this.middleArea.Width,this.middleArea.Height),
> > GraphicsUnit.Pixel);
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0gxBuffer.DrawImage(buttomBar, 0, this.Locatio=
n.Y -
> > buttomBar.Height);
> > =A0 =A0 =A0 =A0 =A0 =A0 e.Graphics.DrawImage(offScreen, 0, 0);
> > =A0 =A0 =A0 =A0 }
>
> > although when i place the middleArea image in a picturebox and stretch
> > it, it works well....
> > any pointers would be really apreciated
>
> > Thanks
>
> Not really sure without seeing the rest of your code, but it could be
> related to:
>
> this.Location+topBar.Height
>
> because this.Location is a Point. =A0I haven't tested what result is
> returned when you do this (perhaps increment both X and Y values?).
>
> - Jin- Hide quoted text -
>
> - Show quoted text -

Hi,
i tried stretcing it to the whole screen
(Rectangle(0,0,this.Width,this.Height) without using this.Location
+topBar.Height), incremented both X and Y, X alone everything it just
wont draw correctly, here's the rest of the code

public partial class Form2 : Form
{
Bitmap offScreen;
Bitmap topBar;
Bitmap buttomBar;
Bitmap middleBar;
Graphics gxBuffer;
string path;

public Form2()
{
InitializeComponent();
path =3D
System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().Co=
deBase);
topBar =3D new Bitmap(path + @"\mbTopBar.png");
middleBar =3D new Bitmap(path + @"\mbMiddle.png");
buttomBar =3D new Bitmap(path + @"\mbButtom.png");
offScreen =3D new Bitmap(this.Width, this.Height);
gxBuffer =3D Graphics.FromImage(offScreen);

}

public Form2(int param_Width, int param_Height)
{
InitializeComponent();
this.Size =3D new Size(param_Width, param_Height);
path =3D
System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().Co=
deBase);
topBar =3D new Bitmap(path + @"\mbTopBar.png");
middleBar =3D new Bitmap(path + @"\mbMiddle.png");
buttomBar =3D new Bitmap(path + @"\mbButtom.png");
offScreen =3D new Bitmap(this.Width, this.Height);
gxBuffer =3D Graphics.FromImage(offScreen);

}


protected override void OnPaint(PaintEventArgs e)
{
gxBuffer.DrawImage(topBar, 0, 0);
gxBuffer.DrawImage(middleArea,new
Rectangle(0,this.Location+topBar.Height,this.Width,this.Height),new
Rectangle(0,0,this.middleArea.Width,this.middleArea.Height),GraphicsUnit.Pix=
el);
gxBuffer.DrawImage(buttomBar, 0, this.Location.Y -
buttomBar.Height);
e.Graphics.DrawImage(offScreen, 0, 0);
}


}
}

thanks for your help