SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Plugin Development

Reply
 
Thread Tools Display Modes
Old 27/06/2018, 01:07 PM   #1
[HLF]Southclaw
High-roller
 
[HLF]Southclaw's Avatar
 
Join Date: Apr 2009
Location: England
Posts: 4,963
Reputation: 1550
Default Bitmapper for object placement

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:

Code:
sampctl package install Southclaws/samp-bitmapper
Or, if you prefer GitHub:

Include in your code and begin using the library:

Code:
#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:

Code:
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:

Code:
make build-debian
(thanks to maddinat0r for the Docker images!)
__________________
Tools:

Plugins:

Links:

[HLF]Southclaw is online now   Reply With Quote
Old 27/06/2018, 01:13 PM   #2
TommyB
Beta Tester
 
TommyB's Avatar
 
Join Date: Sep 2010
Location: Texas, USA.
Posts: 177
Reputation: 145
Default Re: Bitmapper for object placement

southclaws moments before release

+rep
__________________

Last edited by TommyB; 27/06/2018 at 02:11 PM.
TommyB is online now   Reply With Quote
Old 27/06/2018, 01:19 PM   #3
PT
Godfather
 
PT's Avatar
 
Join Date: Nov 2012
Location: Portugal
Posts: 7,205
Reputation: 775
Default Re: Bitmapper for object placement

+rep

Nice JOB!
__________________
"Quem caiu e se levantou honrado era e honrado ficou..."


CVU vai voltar e.e


http://steamcommunity.com/id/pt_player/
PT is online now   Reply With Quote
Old 27/06/2018, 02:20 PM   #4
Dignity
High-roller
 
Dignity's Avatar
 
Join Date: May 2013
Location: Belgium
Posts: 1,933
Reputation: 1118
Default Re: Bitmapper for object placement

Nice! Thanks for clarifying
Dignity is offline   Reply With Quote
Old 27/06/2018, 02:59 PM   #5
Romz
High-roller
 
Romz's Avatar
 
Join Date: Jun 2013
Location: Ukraine
Posts: 1,055
Reputation: 64
Default Re: Bitmapper for object placement

Good.
__________________
Romz is online now   Reply With Quote
Old 27/06/2018, 04:51 PM   #6
coool
Gangsta
 
coool's Avatar
 
Join Date: Feb 2013
Location: Republic of Pakistan
Posts: 586
Reputation: 39
Default Re: Bitmapper for object placement

Nice one
__________________
coool is offline   Reply With Quote
Old 01/07/2018, 09:49 AM   #7
CodeStyle175
Banned
 
Join Date: Apr 2014
Posts: 473
Reputation: 35
Default Re: Bitmapper for object placement

so what can i do with this bitmap for example?
CodeStyle175 is offline   Reply With Quote
Old 01/07/2018, 12:34 PM   #8
[HLF]Southclaw
High-roller
 
[HLF]Southclaw's Avatar
 
Join Date: Apr 2009
Location: England
Posts: 4,963
Reputation: 1550
Default Re: Bitmapper for object placement

Quote:
Originally Posted by CodeStyle175 View Post
so what can i do with this bitmap for example?
See the second sentence of the thread for example.
__________________
Tools:

Plugins:

Links:

[HLF]Southclaw is online now   Reply With Quote
Old 01/07/2018, 04:56 PM   #9
CodeStyle175
Banned
 
Join Date: Apr 2014
Posts: 473
Reputation: 35
Default Re: Bitmapper for object placement

still i dont get it why would i need to do something stupid like this, why would i need to add lagging objects randomly in some array with no reason?
CodeStyle175 is offline   Reply With Quote
Old 01/07/2018, 06:47 PM   #10
coool
Gangsta
 
coool's Avatar
 
Join Date: Feb 2013
Location: Republic of Pakistan
Posts: 586
Reputation: 39
Default Re: Bitmapper for object placement

Quote:
Originally Posted by CodeStyle175 View Post
still i dont get it why would i need to do something stupid like this, why would i need to add lagging objects randomly in some array with no reason?
I don't know about the lagging stuff but
Quote:
Originally Posted by [HLF]Southclaw View Post
See this thread for the primary reason that this plugin exists.
__________________
coool is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Realistic vehicle placement: VeryTallMidget General 5 26/10/2018 02:00 PM
Bitmapping Object Placement [HLF]Southclaw Discussion 16 31/12/2017 12:01 PM
Mapping Placement kvsolga General 7 05/08/2011 12:12 PM


All times are GMT. The time now is 01:44 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.