Board logo

标题: [原创] vbs画色图 [打印本页]

作者: jyswjjgdwtdtj    时间: 2023-6-4 17:30     标题: vbs画色图

本帖最后由 jyswjjgdwtdtj 于 2023-6-5 20:33 编辑

重点:vector.add的类型一定是要long!每个变量都要clng!
  1. set vector=createobject("wia.vector")
  2. for i=&h00 to &hff
  3. for j=&h00 to &hff
  4. vector.add 65280+i+256*256*j
  5. next
  6. next
  7. vector.ImageFile(256,256).savefile "1.jpg"
复制代码
  1. set vector=createobject("wia.vector")
  2. c1=array(&hca,&h0c,&h9f)
  3. c2=array(&hff,&hd3,&h0c)
  4. r=c1(0)-c2(0)
  5. g=c1(1)-c2(1)
  6. b=c1(2)-c2(2)
  7. t=&hff
  8. for i=&h00 to t
  9. num=clng(c1(2)-i/(t+1)*b)+&h100*clng(c1(1)-i/(t+1)*g)+&h10000*clng(c1(0)-i/(t+1)*r)
  10. for aaaa=&h00 to &hff
  11. vector.add num
  12. next
  13. next
  14. vector.ImageFile(256,t+1).savefile "1.jpg"
复制代码
  1. '嘿嘿 用一次函数和用错误排除浪费了性能 但是简单啊:lol
  2. set vector=createobject("wia.vector")
  3. c1=array(&hff,&h62,&h6e)
  4. c2=array(&hff,&hbe,&h71)
  5. r=c1(0)-c2(0)
  6. g=c1(1)-c2(1)
  7. b=c1(2)-c2(2)
  8. t=&hff
  9. l=&hff
  10. dim p()
  11. redim p(t,l)
  12. k=t/l'k为斜率
  13. function f(x,t)
  14. f=k*x+t
  15. end function
  16. call a
  17. function a
  18. on error resume next
  19. for i=-t to t't为截距
  20. num=clng(c1(2)-i/(t+1)*b)+&h100*clng(c1(1)-i/(t+1)*g)+&h10000*clng(c1(0)-i/(t+1)*r)
  21. for j=0 to l
  22. p(j,f(j,i))=num
  23. next
  24. next
  25. end function
  26. for i=0 to t
  27. for j=0 to l
  28. vector.add p(i,j)
  29. next
  30. next
  31. vector.ImageFile(l+1,t+1).savefile "1.jpg"
复制代码

作者: LTSC1809    时间: 2023-6-4 19:05

回复 1# jyswjjgdwtdtj 还要归功于微软的WSH,自带这么多对象
作者: jyswjjgdwtdtj    时间: 2023-6-4 19:20

回复 2# LTSC1809


    这不是wsh哦  这是com组件
作者: Five66    时间: 2023-6-6 21:25

看不懂为啥类型一定要 long
作者: jyswjjgdwtdtj    时间: 2023-6-6 21:47

回复 4# Five66


    可能是类型转换的时候int会变成负数吧
作者: segree    时间: 2023-7-16 18:01

  1. dim ar,Range,Img
  2. ar=Array(&HFFFFFFFF, &HFFFFFFFF, &HFF000000, &HFF000000, &HFF000000, &HFF000000, &HFFFFFFFF, &HFFFFFFFF, &HFFFFFFFF, &HFF000000, &HFF000000, &HFFFFFFFF, &HFFFFFFFF, &HFF000000, &HFF000000, &HFFFFFFFF, &HFF000000, &HFF000000, &HFFFFFFFF, &HFFFFFFFF, &HFFFFFFFF, &HFFFFFFFF, &HFF000000, &HFF000000, &HFF000000, &HFF000000, &HFFFFFFFF, &HFFFFFFFF, &HFFFFFFFF, &HFFFFFFFF, &HFF000000, &HFF000000, &HFFFFFFFF, &HFF000000, &HFF000000, &HFFFFFFFF, &HFFFFFFFF, &HFF000000, &HFF000000, &HFF000000, &HFFFFFFFF, &HFFFFFFFF, &HFF000000, &HFF000000, &HFF000000, &HFFFFFFFF, &HFF000000, &HFF000000, &HFFFFFFFF, &HFFFFFFFF, &HFFFFFFFF, &HFFFFFFFF, &HFFFFFFFF, &HFFFFFFFF, &HFF000000, &HFF000000, &HFFFFFFFF, &HFF000000, &HFFFFFFFF, &HFFFFFFFF, &HFFFFFFFF, &HFFFFFFFF, &HFF000000, &HFF000000, &HFFFFFFFF, &HFF000000, &HFF000000, &HFFFFFFFF, &HFFFFFFFF, &HFF000000, &HFF000000, &HFFFFFFFF, &HFFFFFFFF, &HFFFFFFFF, &HFF000000, &HFF000000, &HFF000000, &HFF000000, &HFFFFFFFF, &HFFFFFFFF)
  3. Set Range = CreateObject("WIA.Vector")
  4. Set Img = CreateObject("WIA.ImageFile")
  5.   For i = 1 To 80*30
  6.     Range.Add ar(i)
  7.      
  8.   Next
  9. Img.ImageFile(80,30).SaveFile "1." & Img.FileExtension
复制代码
WIA.Vector菜鸟一枚,不懂用这来画个简单图,求高手指教。




欢迎光临 批处理之家 (http://bathome.net./) Powered by Discuz! 7.2