stretchblt_stretchblt CImage_stretchblt 失败

电脑杂谈  发布时间:2017-02-11 03:00:23  来源:网络整理

stretchblt_stretchblt 失败_stretchblt CImage

stretchbltstretchblt

I am trying to copy a bitmap image from a file to a picbox (on a form) using stretchblt. I am having and issue with getting the handle to the bitmap graphic.

I have included the entire code below (it is marked at line 38 where I think my issue is)

To execute it just build a new Windows Form project and add a button (button1) and a picture box (picturebox1)

then add a small bitmap image to your c:\ (root) named C:\test2.bmp

I have attached the .bmp file I used but any smaller .bmp file should work.

(BTW - I know there are other ways of doing what I ask but I MUST use the Strechblt command so other solutions can be ignored)

Thank You

I would appreciate any help...

the code to plug into the form follows...

START OF CODE_________________________________

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Drawing.Printing;

using System.Text;

using System.Windows.Forms;

using System.Runtime.InteropServices;

namespace WindowsFormsTestBlt

{

stretchblt 失败_stretchblt_stretchblt CImage

public partial class Form1 : Form

{

/// StretchBlt

[DllImport("GDI32.DLL", CharSet = CharSet.Auto, SetLastError = true, ExactSpelling = true)]

public static extern bool StretchBlt(IntPtr hdcDest, int nXDest, int nYDest, int nDestWidth, int nDestHeight,

IntPtr hdcSrc, int nXSrc, int nYSrc, int nSrcWidth, int nSrcHeight, Int32 dwRop);

public Form1()

{

InitializeComponent();

}

public void renderTextLineFromBitmap()

{

//get bmp from a file

Bitmap bmp = (System.Drawing.Bitmap)Image.FromFile("C:\\test2.bmp");


本文来自电脑杂谈,转载请注明本文网址:
https://www.pc-fly.com/a/jisuanjixue/article-31712-1.html

相关阅读
    发表评论  请自觉遵守互联网相关的政策法规,严禁发布、暴力、反动的言论

    • 王过仁
      王过仁

      那里边演习的就是阿利伯克级导弹驱逐舰

    • 柳松
      柳松

      配上mv歌更好听

    热点图片
    拼命载入中...