我正在尝试使用以下函数将位图旋转90度.它的问题在于,当高度和宽度不相等时,它会切断部分图像.
注意returnBitmap width = original.height,它的height = original.width
任何人都可以帮我解决这个问题或指出我做错了什么?
private Bitmap rotateImage90(Bitmap b)
{
Bitmap returnBitmap = new Bitmap(b.Height, b.Width);
Graphics g = Graphics.FromImage(returnBitmap);
g.TranslateTransform((float)b.Width / 2, (float)b.Height / 2);
g.RotateTransform(90);
g.TranslateTransform(-(float)b.Width / 2, -(float)b.Height / 2);
g.DrawImage(b, new Point(0, 0));
return returnBitmap;
}
Run Code Online (Sandbox Code Playgroud) 换行是否有助于代码可读性?
是否有一种普遍接受的使用线路延续的礼仪?
为什么用这个:
SomeMethod(int someInt, Object someObject,
String someString, bool someBool)
{
...
}
Run Code Online (Sandbox Code Playgroud)
而不是这个:
SomeMethod(int someInt, Object someObject, String someString, bool someBool)
{
...
}
Run Code Online (Sandbox Code Playgroud)
编辑:从行继续到换行重新措辞我的问题
有没有办法提供用户控件自定义事件,并在用户控件中的事件上调用事件.(我不确定调用是否是正确的术语)
public partial class Sample: UserControl
{
public Sample()
{
InitializeComponent();
}
private void TextBox_Validated(object sender, EventArgs e)
{
// invoke UserControl event here
}
}
Run Code Online (Sandbox Code Playgroud)
和MainForm:
public partial class MainForm : Form
{
private Sample sampleUserControl = new Sample();
public MainForm()
{
this.InitializeComponent();
sampleUserControl.Click += new EventHandler(this.CustomEvent_Handler);
}
private void CustomEvent_Handler(object sender, EventArgs e)
{
// do stuff
}
}
Run Code Online (Sandbox Code Playgroud) 我正在运行VS2005,当我右键单击一个对象并选择Go to Definition时,它会将我带到对象浏览器而不是实际代码.
是否有一些设置可以更改以解决此问题?注意:它适用于C#解决方案,我遇到了Basic的问题.
我在Visual Studio 2005项目中有一堆警告,其中大多数警告我资源名称不是有效的标识符.
例:
The resource name 'MB_ArchiveRestore.cs_11' is not a valid identifier.
Run Code Online (Sandbox Code Playgroud)
MSDN联机帮助表明资源名称需要强类型,不包含空格.强类型的确切含义是什么?
我遇到了无限循环问题.
我有两个数字上/下控制(高度和宽度输入参数).当用户更改其中一个控件的值时,我需要缩放另一个控件以保持高宽比不变.
有没有办法在不调用ValueChanged事件的情况下设置控件的值.我只希望在用户更改值时执行ValueChanged事件.
private void FloorLength_ValueChanged(object sender, EventArgs e)
{
if (this.mCurrentDocument.System.SuperTrakSystem.FloorBitmap != null)
{
FloorWidth.Value = FloorLength.Value *
((decimal)this.mCurrentDocument.System.SuperTrakSystem.FloorBitmap.Height /
(decimal)this.mCurrentDocument.System.SuperTrakSystem.FloorBitmap.Width);
}
}
private void FloorWidth_ValueChanged(object sender, EventArgs e)
{
if (this.mCurrentDocument.System.SuperTrakSystem.FloorBitmap != null)
{
FloorLength.Value = FloorWidth.Value *
((decimal)this.mCurrentDocument.System.SuperTrakSystem.FloorBitmap.Width /
(decimal)this.mCurrentDocument.System.SuperTrakSystem.FloorBitmap.Height);
}
}
Run Code Online (Sandbox Code Playgroud) c# ×7
sql-server ×2
.net ×1
bitmap ×1
casting ×1
coding-style ×1
resources ×1
textbox ×1
vb.net ×1
winforms ×1