Page 1 of 1

GetBrushFromPieceOfPicture

Posted: Fri May 14, 2010 11:26 pm
by Bugala
Since i at least didint receive any answers on how to actually get this done in newbie section, i guess there aint a way in hollywood for this yet, so wishlist request for new command:

GetBrushFromPieceOfPicture(PictureID, BrushID, X, Y, Width, height)

Ie.
GetBrushFromPieceOfPicture(1, 2, 30, 40, 100, 100)

Would result in creating a Brush with ID 2, from picture 1 starting from (30,40) coordinates and takin 100x100 piece from that picture.

Thiskind of command have been i nBoth Amos as well as BlitzBasic, but hollywood seems to be missing this kind of option which makes making moving objects from pictures bit time consuming since at least so far only way i can fugre to do this is to use some image manipulation program and making each brush as independent image and then saving them as brush and loading in actrual program.

In Amos and Blitzbasic i just used to do one picture that for example contained all the different images that the character could be having during the game and then just used this... maybe it was GetAShape command in loop in way of:

temp=0
for temp=1 to 10
GetAShape(temp, 102*temp, 10, 100, 100)
next temp

and i would get 10 images grabbed from same picture for my main character to positions 1-10.

Re: GetBrushFromPieceOfPicture

Posted: Sat May 15, 2010 12:41 am
by Allanon
Hi Bugala,
sorry, I didn't noticed your request on newbie section :)
your problem can be resolved with the following code:

SETUP YOUR DISPLAY AS YOU LIKE

Code: Select all

YOUR DISPLAY SETUP
LoadBGPic(n, yourpicture)

DisplayBGPic(n)
STORE PICTURE PART IN A BRUSH

Code: Select all

CreateBrush(n, x, y, w, h)
SelectBrush(n)
   DisplayBGPicPart(id, x, y, width, height[, dx, dy, table])
EndSelect
Please read the documentation about the table options you can pass because if you set here Layers = True all graphics added later the DisplayBGPic() will be copied to the brush otherwise only the background will be selected for the copiy operation.
I use this technique often to save the background I want to restore manually without using the layers so it works (and works well ;) )

You can do the same loading the picture in a brush and then, using the same SelectBrush technique, you can use DisplayBrushPart() to cut the area you want in your brush.

Hope to have helped

Allanon

Re: GetBrushFromPieceOfPicture

Posted: Wed May 19, 2010 6:44 pm
by airsoftsoftwair
You can also use CropBrush() or specify a tile with LoadBrush() or @BRUSH directly, e.g.

LoadBrush(1, "test.png", {X = 100, Y = 100, Width = 50, Height = 50})

This will load a tile from the boundaries (100,100,150,150) inside test.png into brush 1. You can do the same with @BRUSH. Or, if you already have a brush, use CropBrush().

Re: GetBrushFromPieceOfPicture

Posted: Sun May 23, 2010 12:37 pm
by Bugala
Thanks Allanon, i used your system to get through my problem.

Although now that i saw Andreas answer too, i think hes system is what will work in this case better, but since i already made it, why btoher changing it anymore. But next time i will use Andreas technic.

I hope to have something to show you soon thanks to your tips.