Вам нужно масштабировать изображение во время OnPaint например ::
if (this._image != null)
{
int x = (this.Width - this._image.Width) / 2;
int y = (this.Height - this._image.Height) / 2;
var imgRect = new Rectangle(x, y, this._image.Width, this._image.Height);
var imageAttr = new ImageAttributes();
Color clr = this._image.GetPixel(0, 0);
imageAttr.SetColorKey(clr, clr);
gr2.DrawImage(this._image, imgRect, 0, 0, this._image.Width, this._image.Height, GraphicsUnit.Pixel, imageAttr);
}
Выше приведен пример, как нарисовать изображение прозрачным цветом на основе первого пикселя. Теперь вам нужно изменить вторые 3 строки:
bool qvga = Screen.PrimaryScreen.Bounds.Height == 240 || Screen.PrimaryScreen.Bounds.Width == 240;
int x = (this.Width - (qvga ? this._image.Width : this._image.Width * 2)) / 2;
int y = (this.Height - (qvga ? this._image.Height : this._image.Height * 2)) / 2;
var imgRect = new Rectangle(x, y, (qvga ? this._image.Width : this._image.Width * 2), (qvga ? this._image.Height : this._image.Height * 2));
[Изменить]
Наблюдение за изменением вашего кода просто. Как я описал в комментарии: для двух основных разрешений Windows Mobile, QVGA и VGA, мы предполагаем, что изображение соответствует размеру QVGA. Пожалуйста, конвертируйте мой код в VB самостоятельно. Так что установите флаг qvga, как я написал:
bool qvga = Screen.PrimaryScreen.Bounds.Height == 240 || Screen.PrimaryScreen.Bounds.Width == 240;
теперь основано на флаге ammend следующим, основываясь на моем коде выше:
Dim imageLeft As Integer = (Me.Width - m_image.Width) / 2
Dim imageTop As Integer = (Me.Height - m_image.Height) / 2
а затем вот эти:
If Not bPushed Then
imgRect = New Rectangle(imageLeft, imageTop, m_image.Width, m_image.Height)
Else
'The button was pressed
'Shift the image by one pixel
imgRect = New Rectangle(imageLeft + 1, imageTop + 1, m_image.Width, m_image.Height)
End If