ID:2611475
 
(See the best response by Magicsofa.)
Problem description:
I generate images for displaying weapons in all slots, but for correct display, I need to cut out parts from the image (shown in black in the screenshot)
I can't just draw the sprites, since the sprite itself consists of parts and it is formed from other sprites and displacements can occur.
https://prnt.sc/ubrmrj
You could make it an underlay, then it will be drawn "behind" the object
In response to Magicsofa
The problem is that the person's icon is solid, and I need to cut a piece from the sprite for an adequate representation with some limbs. for example, so that the hand is higher than the image.
Best response
I'm not sure I understand what exactly you are trying to do. Are you building new icons at runtime in order to display the equipment? If that's the case, I'd recommend using a different strategy. The icon procs are fine for something like building a sprite, but once you are layering it with other sprites you should be at least using the overlays/underlays vars. If you wanted more control over them you could attach them as separate objects like particles, but you may not need that at all. Overlays and underlays match the direction of the object they are attached to, and if you attach a whole icon (instead of just a single state) then they will also match the icon state of the object. Then you could either cut out the appropriate part in the icon itself, or have the layering change dynamically when the player moves.
In response to Magicsofa
I explain the essence in more detail:
There is an icon of a person, clothes are superimposed on it in layers and all that.
I shape the image by overlaying it with a certain offset, so that each overlay forms one weapon. Then I take the image of the character, cut off the extra layers and make a layer out of this, which needs to be cut out from the made weapon, so that the already changed sprite can be applied to the character.
Simply put, I need to either make the black area invisible or cut it out completely
If you really must do this whole masking thing, you could use GetPixel() and DrawBox(). Just draw a transparent pixel at the same coordinates as each non-transparent pixel in the player icon. But I still think it would be a lot easier to just use layering to achieve the same effect. That way, the player can be any shape, and you won't need to re-draw the weapon.

client/North()
mob.underlays = list('gun.dmi')
mob.overlays = null
..()
client/West()
mob.underlays = list('gun.dmi')
mob.overlays = null
..()
client/South()
mob.underlays = null
mob.overlays = list('gun.dmi')
..()
client/East()
mob.underlays = null
mob.overlays = list('gun.dmi')
..()


In response to Magicsofa
Then there is a problem with the side view on the belt, the icon overlaps the hand
The method I want to use is shaping an aflf mask, but I don't fully understand how to use it.
Then you will need a separate graphic for the hand, so that it can be on a different layer.

I don't know what "aflf" means. But like I said, you could use the icon procs to mask out portions of an icon at runtime:

   var
icon/I = new('gun.dmi')
icon/J = new('player.dmi'
X
Y
pix
for(X = 1 to 32)
for(Y = 1 to 32)
pix = J.GetPixel(X, Y)
if(pix)
I.DrawBox(null, X, Y)


Selecting out the hand would still be an issue, but it could be done by hardcoded values, or by having special colors for the hand that aren't present in the rest of the icon. GetPixel() returns null if the pixel is transparent, but if not it will give you the color as "#RRGGBB". Thus, you could have special colors to mark "on top" portions. By just adding or subtracting 1 from even a single color component, it could be detectable by GetPixel() but not by players...