Project Perfect Mod Forums
:: Home :: Get Hosted :: PPM FAQ :: Forum FAQ :: Privacy Policy :: Search :: Memberlist :: Usergroups :: Register :: Profile :: Log in to check your private messages :: Log in ::


The time now is Wed Nov 27, 2024 8:27 pm
All times are UTC + 0
[Dev Info] BS SHP Builder: CCMs -> New Engine!
Moderators: stucuk
Post new topic   Reply to topic Page 1 of 1 [1 Post] Mark the topic unread ::  View previous topic :: View next topic
Author Message
Banshee
Supreme Banshee


Also Known As: banshee_revora (Steam)
Joined: 15 Aug 2002
Location: Brazil

PostPosted: Fri Apr 02, 2004 1:35 am    Post subject:  [Dev Info] BS SHP Builder: CCMs -> New Engine! Reply with quote  Mark this post and the followings unread

Note: This info is originally written to Stucuk, but if you plan to edit this tool one day, it will be interesting to learn it Wink.

First of all, be aware that the old CCM engine still work.

Here's the structure of the new engine:

Code:
// The New CCM Engine

// Initialization Procedures
Procedure GenerateColourList(Palette:TPalette; var List,Last:listed_colour; BGColour : Tcolor; IgnoreBackground,IgnoreShadow,IgnoreGlowingColours:Boolean);
Procedure PrepareBank(var Start:colour_element; List,Last:listed_colour);

// Auto Selection Algorithm
function AutoSelectALG_Progress(ProgressBar : TProgressBar; Bitmap:TBitmap; SHPPalette:TPalette; List,Last: listed_colour) : byte; overload;

// Frame Loading Procedures
Procedure LoadFrameImageToSHP(var SHP:TSHP; const Frame:integer; const Bitmap:TBitmap; var List,Last:listed_colour; var Start:colour_element; alg : byte); overload;
Function LoadFrameImageToSHP(const Bitmap : TBitmap; const SHPPalette:TPalette; var List, Last: listed_colour; alg : byte) : real; overload;

// Pixel Loading Functions
function LoadPixel(const Bitmap:TBitmap; var Start:colour_element; var List,Last : listed_colour; alg : byte; x,y : integer) : integer; overload;
function LoadPixel(const Bitmap:TBitmap; var List,Last : listed_colour; alg : byte; x,y : integer) : integer; overload;

// Colour Conversion Methods: Functions
function RGBDiff(Colour : TColor; var List,Last:listed_colour) : byte;
function RGBAdvDifference(Colour : TColor; var List,Last:listed_colour) : byte;
function RGBDifference(Colour : Tcolor; var List,Last : listed_colour) : byte;
function RGB3DFullDiff(Colour : Tcolor; var List,Last:listed_colour) : byte;
function RGB3DColourPlus(Colour : Tcolor; var List,Last:listed_colour) : byte;
Function RGB3DInfurium(Color : Tcolor; var List,Last:listed_colour; Bitmap:TBitmap; x,y:integer) : byte;



The way to use it is simple. Make sure that the form or unit that your new feature will be written loads the following libraries:

SHP_Engine_CCMs; SHP_Colour_Bank; Colour_list;

In the function of your new feature, create the following variables:

Code:
var
Start : colour_element;
List, Last: listed_colour;



when you are loading the settings for the conversion, use the GenerateColourList(), so the colours that will be used in the conversion will be known. And use PrepareBank() to prepare the cache.


To convert each frame, use LoadFrameImageToSHP(); Here's a sample from FrmImportImageAsSHP:

Code:
      // Load frame
      LoadFrameImageToSHP(FrmMain.SHP,(x - start) +1,Bitmap,List,Last,Start,alg);


FrmMain.SHP = SHP used in the operation
(x - start) + 1 = number of the frame
Bitmap = Current Bitmap (24bits) version of the image that is being converted.
List = first colour of the Colour List of colours from the palette that can be used in the conversion
Last = last colour of the Colour List of colours from the palette that can be used in the conversion (this is not much used but kept as default)
Start = The first element of the Colour Bank, that avoids colours from being checked more than once, speeding up the operation.
alg = number of CCM that will be used: 1 for R,G,B Difference; 2 for R+G+B Advanced Difference; 3 for R+G+B Difference; 4 for 3D RGB Fulld Difference; 5 for 3D RGB Full Difference Colour+ and 6 for 3D RGB Infurium. Note: Infurium doesnt use Colour Banks!


And finally, after all frames are converted, you should eliminate the cached info and colour list by using the following codes:

Code:

// Remove the trash:
ClearColourList(List,Last);
ClearBank(Start);



I dont see this as being hard and it makes conversion really faster. And, finally, I cant forget to mention the AutoSelect Algorithm that was also changed, although the name of the function is still the same it used to be:

Code:
  alg := AutoSelectALG_Progress(ProgressBar,Bitmap,SHPPalette,List,Last);


Of course, change the palette, bitmap and other stuff to the name of the variables used in your function.


If, for some reason, you wanna make special versions of these functions, overload it, so the names won't be confusing, since they will be the same, but try using this system...

Back to top
View user's profile Send private message Visit poster's website Skype Account
Display posts from previous:   
Post new topic   Reply to topic Page 1 of 1 [1 Post] Mark the topic unread ::  View previous topic :: View next topic
 
Share on TwitterShare on FacebookShare on Google+Share on DiggShare on RedditShare on PInterestShare on Del.icio.usShare on Stumble Upon
Quick Reply
Username:


If you are visually impaired or cannot otherwise answer the challenges below please contact the Administrator for help.


Write only two of the following words separated by a sharp: Brotherhood, unity, peace! 

 
You cannot post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © phpBB Group

[ Time: 0.2414s ][ Queries: 11 (0.0081s) ][ Debug on ]