ZBrushCentral

Question: Write pixol back into canvas?

I am exploring an idea for a plugin/tool that interacts with the canvas. Getting data out of the canvas is relatively easy with [PixolPick] and a memory buffer:
Test code:

[VarSet, width, (Document:Width)]
[VarSet, height, (Document:Height)]

// [Caption, [StrMerge, "Document size:", width, " ", height]]
[MemCreate, canvasColor, width * height * 4]
[loop, height, 
      [loop, width,
         [MemWrite, canvasColor, [PixolPick, 0, x, y], 6, (y * width + x) * 4]
         [MemWrite, canvasColor, 255, 2, (y * width + x) * 4 + 3]
      ,x]
,y]
[MemSaveToFile, canvasColor, "C:\Users\jens\Documents\ZScript\canvasColor.bin", 1]

That only gets me half way, and I need to find a way to write data back into the canvas. There doesn’t seem to be an equivalent [pixolput] function. Any idea? Do I have to simulate brush strokes or something?
(This is not for an actual product, yet, this is the initial “is this possible?” research phase.)

Welcome to ZBC! :grinning:

You would have to simulate a brush stroke in some way. There are various ways to do this, such as loading brush strokes from a file, using [CanvasClick] and so on. Whether any of these will do what you want will depend on what you want to do!

This is the result of my experiments:


I finished this quite some time ago, but just remembered to post this here as well for others as reference. I can’t give much support for this, as my evaluation license has expired.

So, in short: Getting the data out of the canvas is quite slow, and I don’t think there is an efficient way to write the data back, especially when you want exact values. Maybe someone with more experience in ZScript has more success…

Not sure if it is possible using the GoZ API. Maybe I’ll request API access when I have my DLL working by itself. Maybe I’ll just do a stand-alone app instead.

Message me…