您的位置:程序门 -> vb -> 基础类



【关于画图程序】


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


【关于画图程序】[已结贴,结贴人:liulhack]
发表于:2007-02-10 16:35:55 楼主
the   first   one:怎样实现图象的添充?
the   next   one:怎样改变某张图片的象素,并将其保存?
the   last   one:怎样保存用picture的line,circle……方法绘制的图片?(此点最重要)
发表于:2007-02-10 16:46:431楼 得分:0
把图片,用paintpicture   可以得到没像素的rgb值,可以直接对每像素操作(用for   语句),喝高了,请别的兄弟给元代吗···
发表于:2007-02-11 14:21:352楼 得分:0
太简略了,只有一个人回答吗?唉~~~郁闷..........
发表于:2007-02-11 19:16:523楼 得分:20
保存用picture的line,circle……方法绘制的图片

http://zhidao.baidu.com/question/20086889.html
百度网友 "鲸无敌 "的代码,径调试无误:
按command1按钮保存picture1区域的图片
option   explicit    
private   const   bi_rgb   =   0&  
private   const   dib_rgb_colors   =   0   '     color   table   in   rgbs  
private   const   bitmaptype   =   &h4d42  
private   const   invalid_handle_value   =   (-1)  
private   const   generic_write   =   &h40000000  
private   const   create_always   =   2  
private   const   file_attribute_normal   =   &h80  

private   type   bitmapinfoheader   '40   bytes  
                bisize   as   long  
                biwidth   as   long  
                biheight   as   long  
                biplanes   as   integer  
                bibitcount   as   integer  
                bicompression   as   long  
                bisizeimage   as   long  
                bixpelspermeter   as   long  
                biypelspermeter   as   long  
                biclrused   as   long  
                biclrimportant   as   long  
end   type  
private   type   rgbquad  
                rgbblue   as   byte  
                rgbgreen   as   byte  
                rgbred   as   byte  
                rgbreserved   as   byte  
end   type  
private   type   bitmapinfo  
                bmiheader   as   bitmapinfoheader  
                bmicolors   as   rgbquad  
end   type  
private   type   bitmapfileheader  
                bftype   as   integer  
                bfsize   as   long  
                bfreserved1   as   integer  
                bfreserved2   as   integer  
                bfoffbits   as   long  
end   type  

private   declare   function   createcompatibledc   lib   "gdi32 "   (byval   hdc   as   long)   as   long  
private   declare   function   createdibsection   lib   "gdi32 "   (byval   hdc   as   long,   pbitmapinfo   as   bitmapinfo,   byval   un   as   long,   lplpvoid   as   long,   byval   handle   as   long,   byval   dw   as   long)   as   long  
private   declare   function   deletedc   lib   "gdi32 "   (byval   hdc   as   long)   as   long  
private   declare   function   deleteobject   lib   "gdi32 "   (byval   hobject   as   long)   as   long  
private   declare   function   selectobject   lib   "gdi32 "   (byval   hdc   as   long,   byval   hobject   as   long)   as   long  
private   declare   function   bitblt   lib   "gdi32 "   (byval   hdestdc   as   long,   byval   x   as   long,   byval   y   as   long,   byval   nwidth   as   long,   byval   nheight   as   long,   byval   hsrcdc   as   long,   byval   xsrc   as   long,   byval   ysrc   as   long,   byval   dwrop   as   long)   as   long  
private   declare   function   createfile   lib   "kernel32 "   alias   "createfilea "   (byval   lpfilename   as   string,   byval   dwdesiredaccess   as   long,   byval   dwsharemode   as   long,   byval   lpsecurityattributes   as   long,   byval   dwcreationdisposition   as   long,   byval   dwflagsandattributes   as   long,   byval   htemplatefile   as   long)   as   long  
private   declare   function   writefile   lib   "kernel32 "   (byval   hfile   as   long,   lpbuffer   as   any,   byval   nnumberofbytestowrite   as   long,   lpnumberofbyteswritten   as   long,   byval   lpoverlapped   as   long)   as   long  
private   declare   function   closehandle   lib   "kernel32 "   (byval   hobject   as   long)   as   long  

private   sub   command1_click()  
        dim   hmemdc   as   long  
        dim   hmembmp   as   long  
        dim   lpmembits   as   long  
        dim   bmp_info   as   bitmapinfo  
        dim   hfile   as   long  
        dim   bmpfile_info   as   bitmapfileheader  
        dim   lpbyteswritten   as   long  
         
        picture1.scalemode   =   vbpixels  
         
        with   bmp_info.bmiheader  
                .bisize   =   lenb(bmp_info.bmiheader)  
                .biwidth   =   picture1.scalewidth  
                .biheight   =   picture1.scaleheight  
                .biplanes   =   1  
                .bibitcount   =   24  
                .bicompression   =   bi_rgb  
                .bisizeimage   =   .biheight   *   (((.biwidth   *   .bibitcount   +   31)   and   &hffffffe0)   \   8)  
        end   with  
         
        hmemdc   =   createcompatibledc(picture1.hdc)  
        hmembmp   =   createdibsection(picture1.hdc,   bmp_info,   dib_rgb_colors,   lpmembits,   0,   0)  
        selectobject   hmemdc,   hmembmp  
         
        bitblt   hmemdc,   0,   0,   bmp_info.bmiheader.biwidth,   bmp_info.bmiheader.biheight,   picture1.hdc,   0,   0,   vbsrccopy  
         
        hfile   =   createfile(app.path   &   "\test.bmp ",   generic_write,   0,   0,   create_always,   file_attribute_normal,   0)  
        if   hfile   <>   invalid_handle_value   then  
                with   bmpfile_info  
                        .bftype   =   bitmaptype  
                        .bfoffbits   =   14   +   bmp_info.bmiheader.bisize  
                        .bfsize   =   .bfoffbits   +   bmp_info.bmiheader.bisizeimage  
                end   with  
                 
                writefile   hfile,   bmpfile_info.bftype,   2,   lpbyteswritten,   0  
                writefile   hfile,   bmpfile_info.bfsize,   12,   lpbyteswritten,   0  
                writefile   hfile,   bmp_info.bmiheader,   bmp_info.bmiheader.bisize,   lpbyteswritten,   0  
                writefile   hfile,   byval   lpmembits,   bmp_info.bmiheader.bisizeimage,   lpbyteswritten,   0  
                 
                closehandle   hfile  
        end   if  
         
        deleteobject   hmembmp  
        deletedc   hmemdc  
end   sub  
发表于:2007-02-11 21:39:514楼 得分:0
保存用picture的line,circle……方法绘制的图片

http://zhidao.baidu.com/question/20086889.html
百度网友zaqryu的代码,较前一代码简单:

private   sub   command1_click()  
commondialog1.defaultext   =   ".bmp "  
commondialog1.filter   =   "bitmap   image   (*.bmp) ¦*.bmp "  
commondialog1.showsave  
if   commondialog1.filename   <>   " "   then  
savepicture   picture1.picture,   commondialog1.filename  
end   if  
end   sub  
发表于:2007-02-12 11:22:565楼 得分:0
百度网友zaqryu的代码只能储存picturebox控件装载的图片。
百度网友 "鲸无敌 "的代码,可储存在picturebox控件上画图的结果。
发表于:2007-02-12 13:47:376楼 得分:0
哦,谢了,那么关于第一,二个问题呢?有谁能赐教~~


快速检索

最新资讯
热门点击