aardio 官方社区

 找回密码
 注册会员

QQ登录

只需一步,快速开始

搜索
查看: 11632|回复: 5

创建位图并调用C函数在上面画一副3D心形图

[复制链接]

8

主题

36

回帖

273

积分

二级会员

积分
273
发表于 2017-12-2 12:30:00 | 显示全部楼层 |阅读模式
涉及到图形学,有比较复杂的数学计算,所以绘制过程可能会比较耗时,效果图就不上了,看代码执行结果吧。。。
/*Bitmap{{*/
createBitmap =
function(w=0, h=0, c=32){
    c = c<32 ? 24 : 32
   
var len = (c>>3) * w * h
   
return {
        struct bmfHeader = {
            WORD bfType = 0x4D42;
            int  bfSize = 54 + len;
            WORD bfReserved1;
            WORD bfReserved2;
            int  bfOffBits = 54;
            _struct_aligned = 2;
        };
        struct bmiHeader = {
            INT  biSize = 40;
            int  biWidth = w;
            int  biHeight = h;
            WORD biPlanes = 1;
            WORD biBitCount = c;
            INT  biCompression;
            INT  biSizeImage = len;
            int  biXPelsPerMeter;
            int  biYPelsPerMeter;
            INT  biClrUsed;
            INT  biClrImportant;
            _struct_aligned = 2;
        };
        byte pixs[] = ..raw.buffer(len)
    }
}
/*}}*/

var code = /**
#include <math.h>

float f(float x, float y, float z)
{
    float a = x * x + 9.0f / 4.0f * y * y + z * z - 1;
    return a * a * a - x * x * z * z * z - 9.0f / 80.0f * y * y * z * z * z;
}

float h(float x, float z)
{
    for (float y = 1.0f; y >= 0.0f; y -= 0.001f)
        if (f(x, y, z) <= 0.0f)
            return y;
    return 0.0f;
}

int mDraw(char* img, int sw, int sh)
{
    int lw = sw*3;
    int i = lw*sh - lw + 2, nextLineOffset = lw * 2;
    for (int sy = 0; sy < sh; sy++)
    {
        float z = 1.5f - sy * 3.0f / sh;
        for (int sx = 0; sx < sw; sx++)
        {
            float x = sx * 3.0f / sw - 1.5f;
            float v = f(x, 0.0f, z);
            int r = 0;
            if (v <= 0.0f)
            {
                float y0 = h(x, z);
                float ny = 0.001f;
                float nx = h(x + ny, z) - y0;
                float nz = h(x, z + ny) - y0;
                float nd = 1.0f / sqrt(nx * nx + ny * ny + nz * nz);
                float d = (nx + ny - nz) / sqrt(3) * nd * 0.5f + 0.5f;
                r = (int)(d * 255.0f);
            }
            img[ i ] = r;
            i += 3;
        }
        i -= nextLineOffset;
    }
    return 0;
}
**/


import win.ui;
/*DSG{{*/
var winform = win.form(text="自绘3D心形图";right=530;bottom=530)
winform.add(
plus={cls=
"plus";left=6;top=6;right=518;bottom=518;z=1}
)
/*}}*/

var w, h = 512, 512
var bmpObj = createBitmap(w, h, 24)
var p = bmpObj.pixs

/**填充随机颜色
..math.randomize()
var rnd = ..math.random
var len = bmpObj.bmiHeader.biSizeImage
for(i=1;len;3){
    p[ i ] = rnd(0, 255)      //b
    p[i+1] = rnd(0, 255)    //g
    p[i+2] = rnd(0, 255)    //r
    //p[i+3] = rnd(0, 255)  //a
}
//**/

import tcc;
var vm = tcc();
vm.compile(code);
vm.mDraw(p, w, h)

var bmp = ..raw.tostring(bmpObj)
winform.plus.foreground = bmp
//..string.save("\Heart.bmp", bmp)

winform.show()
win.loopMessage();

评分

参与人数 1 +40 收起 理由
松江 + 40 很给力!

查看全部评分

38

主题

129

回帖

1045

积分

荣誉会员

积分
1045
发表于 2017-12-2 12:48:35 | 显示全部楼层
谢谢分享

8

主题

36

回帖

273

积分

二级会员

积分
273
 楼主| 发表于 2017-12-9 18:16:44 | 显示全部楼层
无聊把代码稍改了下,把C代码收拾到了dll里,用了多线程,可实时展示绘制进度。。。

  1. /*Bitmap{{*/
  2. class createBitmap{
  3.         ctor(w=0, h=0, c=32){
  4.                 c = c<32 ? 24 : 32
  5.                 var len = ((((c>>3) * w + 3)>>2)<<2) * h
  6.                 this.bf = {
  7.                         WORD bfType = 0x4D42;
  8.                         int  bfSize = 54 + len;
  9.                         WORD bfReserved1;
  10.                         WORD bfReserved2;
  11.                         int  bfOffBits = 54;
  12.                         _struct_aligned = 2;
  13.                 };
  14.                 this.bi = {
  15.                         struct bmiHeader = {
  16.                                 INT         biSize = 40;
  17.                                 int         biWidth = w;
  18.                                 int         biHeight = h;
  19.                                 WORD biPlanes = 1;
  20.                                 WORD biBitCount = c;
  21.                                 INT         biCompression;
  22.                                 INT         biSizeImage = len;
  23.                                 int         biXPelsPerMeter;
  24.                                 int         biYPelsPerMeter;
  25.                                 INT         biClrUsed;
  26.                                 INT         biClrImportant;
  27.                                 _struct_aligned = 2;
  28.                         };
  29.                 //        INT bmiColors[1]
  30.                 }
  31.         }
  32.         struct bf;
  33.         struct bi;
  34.         byte pixs[];
  35. }
  36. /*}}*/

  37. /*dll{{*/
  38. import crypt.bin
  39. var dll = crypt.bin.decodeBase64("TVqQAAMAAAAEAAAA//8AALgAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAA4fug4AtAnNIbgBTM0hVGhpcyBwcm9ncmFtIGNhbm5vdCBiZSBydW4gaW4gRE9TIG1vZGUuDQ0KJAAAAAAAAABQRQAATAEDAAAAAAAAAAAAAAAAAOAADiMLAQYAAAAAAAAAAAAAAAAAwB8AAAAQAAAAMAAAAAAAEAAQAAAAAgAABAAAAAAAAAAEAAAAAAAAAABQAAAAAgAA9PsAAAIAAAAAABAAABAAAAAAEAAAEAAAAAAAABAAAAAwMQAARAAAAKAwAAA8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAEgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADcMAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAC50ZXh0AAAAKBAAAAAQAAAAEgAAAAIAAAAAAAAAAAAAAAAAACAAAGAuZGF0YQAAAIABAAAAMAAAAAIAAAAUAAAAAAAAAAAAAAAAAABAAADALnJlbG9jAABIAAAAAEAAAAACAAAAFgAAAAAAAAAAAAAAAAAAQAAAQgAAAAAAAAAAAAAAAAAAAABVieWB7BgAAACQ2UUI2E0I2VX43djZBQAwABDYTQzYTQzYRfjZVfTd2NlF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形图";right=730;bottom=730)
  49. winform.add(
  50. plus={cls="plus";left=5;top=5;right=725;bottom=725;z=1}
  51. )
  52. /*}}*/

  53. var w, h = 720, 720
  54. var bmpObj = createBitmap(w, h, 24)

  55. var trdfunc = function(winform, bmpObj, dll){
  56.         var hdc = ::User32.GetWindowDC(winform.plus.hwnd)
  57.         var w, h = bmpObj.bi.bmiHeader.biWidth, bmpObj.bi.bmiHeader.biHeight
  58.         bmpObj.pixs = ..raw.buffer(bmpObj.bi.bmiHeader.biSizeImage)
  59.        
  60.         var mDraw = ..raw.loadDll(dll, , "cdecl").mDraw
  61.         mDraw(hdc, bmpObj.bi, bmpObj.pixs, w, h)
  62.        
  63.         ::User32.ReleaseDC(winform.plus.hwnd, hdc)
  64.        
  65.         var bmp = ..raw.tostring(bmpObj)
  66.         winform.plus.foreground = bmp
  67. }

  68. thread.create(trdfunc, winform, bmpObj, dll)

  69. winform.show()
  70. win.loopMessage();
复制代码

点评

同意: 5.0
同意: 5
太帅了  发表于 2017-12-12 13:33

0

主题

8

回帖

64

积分

一级会员

积分
64
发表于 2018-1-14 21:46:26 | 显示全部楼层
最近在疯狂研习您的代码,学到很多有用的东西,太帅啦 感谢无私的奉献,再次鞠躬

0

主题

9

回帖

69

积分

一级会员

积分
69
发表于 2018-4-10 18:29:11 | 显示全部楼层
这个就很强大了,得好好研究一下
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

手机版|未经许可严禁引用或转载本站文章|aardio.com|aardio 官方社区 ( 皖ICP备09012014号 )

GMT+8, 2024-4-19 13:38 , Processed in 0.064940 second(s), 23 queries .

Powered by Discuz! X3.5

Copyright © 2001-2023 Tencent Cloud.

快速回复 返回顶部 返回列表