BGRABitmap图像操作8:另一个阈值控制方式,生成迷彩纹理
2016-09-05 06:28
441 查看
unit Unit1; {$mode objfpc}{$H+} interface uses Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, BGRABitmap, BGRABitmapTypes, BGRAGradients; type { TForm1 } TForm1 = class(TForm) procedure FormPaint(Sender: TObject); private { private declarations } public { public declarations } end; var Form1: TForm1; implementation {$R *.lfm} { TForm1 } function Interp256(value1,value2,position: integer): integer; inline; begin result := (value1*(256-position) + value2*position) shr 8; end; function Interp256(color1,color2: TBGRAPixel; position: integer): TBGRAPixel; inline; begin result.red := Interp256(color1.red,color2.red, position); result.green := Interp256(color1.green,color2.green, position); result.blue := Interp256(color1.blue,color2.blue, position); result.alpha := Interp256(color1.alpha,color2.alpha, position); end; procedure TForm1.FormPaint(Sender: TObject); var image,tex: TBGRABitmap; p: PBGRAPixel; i: Integer; v: Byte; begin image := TBGRABitmap.Create(ClientWidth,ClientHeight); tex := CreateCyclicPerlinNoiseMap(100,100); p := tex.Data; for i := 0 to tex.NbPixels-1 do begin v := p^.red; if v < 64 then p^:= BGRA(31,33,46) else if v < 128 then p^:= BGRA(89,71,57) else if v < 192 then p^:= BGRA(80,106,67) else p^:= BGRA(161,157,121); inc(p); end; image.FillRect(0,0,image.Width,image.Height, tex, dmSet); tex.free; image.Draw(Canvas,0,0,True); image.free; end; end.
相关文章推荐
- BGRABitmap图像操作8:彩色纹理,阈值
- BGRABitmap图像操作8:用正弦函数生成纹理
- BGRABitmap图像操作8:生成纹理,基本的Perlin噪声地图
- BGRABitmap图像操作9c:同时使用莫林杂点和 phong 阴影制作纹理
- BGRABitmap图像操作8:木质纹理
- ASP.NET MVC WebApi 返回数据类型序列化控制(json,xml) 用javascript在客户端删除某一个cookie键值对 input点击链接另一个页面,各种操作。 C# 往线程里传参数的方法总结 TCP/IP 协议 用C#+Selenium+ChromeDriver 生成我的咕咚跑步路线地图 (转)值得学习百度开源70+项目
- BGRABitmap图像操作8:纹理
- BGRABitmap图像操作9:用 phong 阴影制作纹理
- BGRABitmap图像操作10:线型映射,让纹理图贴到多边形的边上
- BGRABitmap图像操作8:纹理,前面椭圆外加一圆角长方形
- BGRABitmap图像操作6:线的两种连接方式
- C语言中将0到1000的浮点数用强制指针类型转换的方式生成一幅图像
- 操作Redis之Jedis对象的生成方式
- BGRABitmap图像操作2:加载一幅图片
- BGRABitmap图像操作1:最简单的例子,在窗体上画一个长方体
- mybatis随机生成可控制主键的方式
- BGRABitmap图像操作4:直接操作像素,颜色校正
- 三种方式实现在一个Activity中控制另一个Activity的UI的更新
- 禁止表单操作及JS控制输入的方式
- BGRABitmap图像操作4:直接操作像素