#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:= # Bitmap2Code by Blizzard # Version: 1.1 # Date: 22.6.2007 # Date 1.1: 10.1.2008 #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:= # # This work is protected by the following license: # #---------------------------------------------------------------------------- # # # # Creative Commons - Attribution-NonCommercial-ShareAlike 3.0 Unported # # ( http://creativecommons.org/licenses/by-nc-sa/3.0/ ) # # # # You are free: # # # # to Share - to copy, distribute and transmit the work # # to Remix - to adapt the work # # # # Under the following conditions: # # # # Attribution. You must attribute the work in the manner specified by the # # author or licensor (but not in any way that suggests that they endorse you # # or your use of the work). # # # # Noncommercial. You may not use this work for commercial purposes. # # # # Share alike. If you alter, transform, or build upon this work, you may # # distribute the resulting work only under the same or similar license to # # this one. # # # # - For any reuse or distribution, you must make clear to others the license # # terms of this work. The best way to do this is with a link to this web # # page. # # # # - Any of the above conditions can be waived if you get permission from the # # copyright holder. # # # # - Nothing in this license impairs or restricts the author's moral rights. # # # #---------------------------------------------------------------------------- # #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:= # # Compatibility # # Does not load normal resource image files. Easy to implement into any # script. 90% chance of full compatibility with SDK. # # # Idea # # Ever made a script, but you need to include several little image files for # it to work? This is not necessary anymore! With the Bitmap2Code converter # you can simply convert bitmap images into RGSS code. Instead of loading the # file into the memory from a file, the bitmap will be generated via code. # # # Function # # This little script allows you to quickly load bitmaps converted to code # with the Bitmap2Code.exe converter. # # # Features # # - instead of loading image files, the bitmaps will be generated via code # - optimizer recognizes same colors and optimizes generated code if possible # - several quality options to simplify code by decreasing the number of # colors # - easy to use: set up the config file, copy the files, run the converter # and just copy paste the generated code into your RGSS Editor # - easy to implement into any script: just call RPG::Cache.load_code("NAME") # instead of the usual bitmap loading methods # # # Example how to load a bitmap: # # bitmap = RPG::Cache.load_code("NAME") # # It is highly recommened to NOT use this converter on files with large # dimensions. If you do so anyway, please read Troubleshooting if you # encounter any problems. Also, read the Bitmap2Code converter readme for # further information. # # # Troubleshooting # # - Problem: # The converter decreases the quality of my bitmaps. # # - Solution: # Set the [Quantization Type] option in the Config.ini to 0 and lossless # conversion will be applied. # # - Problem: # I get the "Script is hanging" error during the conversion. # # - Solution: # This can only happen if you try to convert bitmaps of large dimentions. # There is no possibility to avoid this problem. However, you can decrease # the [Power] option in the Config.ini, but this will also slow down the # conversion. Another solution would be to decrease the quality of the # bitmap. # # # If you find any bugs, please report them here: # http://forum.chaos-project.com #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:= #============================================================================== # module RPG::Cache #============================================================================== module RPG::Cache def self.load_code(file) return nil if file == '' key = [file, 'code'] if !@cache.include?(key) || @cache[key].disposed? eval("@cache[key] = Bitmap2Code.#{file}") end return @cache[key] end end