[Plugin] Bitmapper for object placement
#1

samp-bitmapper

For generating in-game coordinates from a bitmap.

See this thread for the primary reason that this plugin exists. It’s best used with MapAndreas or ColAndreas and a texture map so you can automatically place items in the game world in areas.

Create a bitmap image of the map then paint specific colours over it. Then, load the bitmap and specify which colours you want to cache with OpenBitmapCache. You can then get random points in the image of specific cached colours with GetRandomCachedRGB.

If you want to map larger or smaller bitmaps to areas of the map, use this library to create a virtual canvas to perform the scaling.

For example, this:



Generates this:



See the thread linked above for more examples.

Installation

Simply install to your project:

Код:
sampctl package install Southclaws/samp-bitmapper
Or, if you prefer GitHub:
Include in your code and begin using the library:

Код:
#include <bitmapper>
Usage

Functions

OpenBitmap(const filename[], &Bitmap:handle);

Opens the given file as a bitmap image and stores thefile handle in handle. Returns 0 on success or an error code.

OpenBitmapCache(const filename[], &Bitmap:handle, const colours[], len = sizeof colours);

Opens the given file and caches all pixels that match the colours listed in colours. Returns 0 on success or an error code.

CloseBitmap(Bitmap:handle);

Closes the specified file handle. Returns 0 on success, 1 if the handle is invalid.

GetRGB(Bitmap:handle, x, y, &r, &g, &b);

Looks up the red, green and blue values stored in the specified X and Y coordinates and stores them in the result parameters r, b and g.

GetRandomCachedRGB(Bitmap:handle, colour, &x, &y);

Provides coordinates and RGB information from a random pixel in the bitmap that contains the specified colour.

Testing

You can compile the plugin and test it in a Docker container all with one command:

Код:
make build-e2e
This will:
  • build the plugin inside a Debian docker image
  • build the Pawn package in test/ with sampctl
  • run the server in test/ as a container, also with sampctl
Or you can just do the build process with:

Код:
make build-debian
(thanks to maddinat0r for the Docker images!)
Reply


Messages In This Thread
Bitmapper for object placement - by [HLF]Southclaw - 27.06.2018, 12:07
Re: Bitmapper for object placement - by TommyB - 27.06.2018, 12:13
Re: Bitmapper for object placement - by PT - 27.06.2018, 12:19
Re: Bitmapper for object placement - by Dignity - 27.06.2018, 13:20
Re: Bitmapper for object placement - by Romz - 27.06.2018, 13:59
Re: Bitmapper for object placement - by coool - 27.06.2018, 15:51
Re: Bitmapper for object placement - by CodeStyle175 - 01.07.2018, 08:49
Re: Bitmapper for object placement - by [HLF]Southclaw - 01.07.2018, 11:34
Re: Bitmapper for object placement - by CodeStyle175 - 01.07.2018, 15:56
Re: Bitmapper for object placement - by coool - 01.07.2018, 17:47
Re: Bitmapper for object placement - by [HLF]Southclaw - 01.07.2018, 19:50
Re: Bitmapper for object placement - by CodeStyle175 - 01.07.2018, 20:58
Re: Bitmapper for object placement - by jasperschellekens - 02.07.2018, 10:01
Re: Bitmapper for object placement - by Zeth - 02.07.2018, 10:08
Re: Bitmapper for object placement - by Dignity - 02.07.2018, 10:38
Re: Bitmapper for object placement - by Verc - 02.07.2018, 15:19
Re: Bitmapper for object placement - by TommyB - 19.07.2018, 07:40
Re: Bitmapper for object placement - by Cyber123 - 08.02.2019, 18:02

Forum Jump:


Users browsing this thread: 1 Guest(s)