Memblock users already know this simple trick.
Great for texture painting projects
, it can convert your entire texture library into usable brushes of any shape or size.
All you need are a .PNG brush image
with transparency (any shape) and a texture image
of your choosing.
In this example, the images must match in size because I didn't include any resizing features.
I have attached a brush and texture which work with the demo.
b$="gradient-star.png":t$="grass1.png":Brush=1:load image b$,Brush,1:Texture=2:load image t$,Texture,1
make memblock from image Brush,Brush:make memblock from image Texture,Texture:DataBytes=get memblock size(Brush):TC=get memblock size(Texture)
if DataBytes<>TC then report error "WHERPS! YOUR 2 IMAGES MUST MATCH IN SIZE - super nice catch, from your pals"
NewImage=3:make memblock NewImage,DataBytes:dim DataStream(DataBytes)
for p=0 to DataBytes-1:inc count
if count<4 then DataStream(p)=memblock byte(Texture,p)
if count=4 then DataStream(p)=memblock byte(Brush,p):count=0
write memblock byte NewImage,p,DataStream(p):NEXT
make image from memblock NewImage,NewImage:paste image NewImage,(screen width()/2)-(image width(NewImage)/2),(screen height()/2)-(image height(NewImage)/2),1:save image "BRUSH_"+t$,NewImage:print "BRUSH_"+t$;" saved!":wait key