I display the IRasterImage in scroll view. The OnPain() function as below:
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
if (image == null)
return;
Point pt = AutoScrollPosition;
Graphics gfx = e.Graphics;
int iDrawWidth;
int iDrawHeight;
iDrawWidth = ClientSize.Width - pt.X;
iDrawHeight = ClientSize.Height - pt.Y;
if (iDrawWidth >= image.Width)
iDrawWidth = image.Width;
if (iDrawHeight >= image.Height)
iDrawHeight = image.Height;
iDrawWidth += pt.X;
iDrawHeight += pt.Y;
Rectangle dstRect = new Rectangle(0, 0, iDrawWidth, iDrawHeight);
Rectangle srcRect = new Rectangle(-pt.X, -pt.Y, iDrawWidth, iDrawHeight);
image.Paint(gfx, srcRect, dstRect,RasterPaintProperties.Default);
}
When the image loaded originally it works well. When the Vertical Scroll Bar in the Top and the image will show it's Top and when the Vertical Scroll Bar in the Bottom and the image will show it's Bottom.
But when the image was created from a DIB, like this:
image = RasterImage.FromDib(image.ToDib(RasterConvertToDibType.BitmapInfoHeader));
It doesn't work. When the Vertical Scroll Bar in the Top and the image will show it's Bottom! When the Vertical Scroll Bar in the Bottom and the image will show it's Top! I wonder what's happened.