Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Possible means to speed up Bitmap TONE code?
#1
Well, this is what I wanna speed up within RPGMaker XP...

Code:
#==============================================================================
# ** Bitmap
#------------------------------------------------------------------------------
#  The bitmap class. Bitmaps are expressions of so-called graphics.
#==============================================================================

class Bitmap
  #-------------------------------------------------------------------------
  # * Tone Adjust
  #    r : red adjustment   (defaulted to 0 middle of -255 - 255 range)
  #    g : green adjustment (defaulted to 0 middle of -255 - 255 range)
  #    b : blue adjustment  (defaulted to 0 middle of -255 - 255 range)
  #-------------------------------------------------------------------------
  def tone_adjust(r=0, g=0, b=0)

    # Adjust values to be within -255 to 255 ranges
    r   = tone_ranges(r)
    g   = tone_ranges(g)
    b   = tone_ranges(b)

    # Cycle through the bitmaps pixels
    for x in 0..self.width
      for y in 0..self.height
        #
        # Base mechanics for each pixel
        color = self.get_pixel(x, y)                  # Get single pixel color
        next  if color.alpha == 0                     # Skip if transparent
        rr    = color.red   + r                       # Adjust the red
        gg    = color.green + g                       # Adjust the green
        bb    = color.blue  + b                       # Adjust the blue
        self.set_pixel(x, y, Color.new(rr, gg, bb))   # Replace the pixel
        #
      end
    end

  end 
  #-------------------------------------------------------------------------
  # * Tone Range Adjustment
  #    value : value (forced to stay in -255 to -255 range)
  #-------------------------------------------------------------------------
  def tone_ranges(value)
    value = -255    if value < 255
    value =  255    if value > 255
  end
end

Now within RPGMaker XP:
  • You can hue-adjust bitmaps within a 0-360 range.
  • You can tone adjust sprites, or increase the red, green and/or blue tones in a range of -255 to 255, darkening or lightening them accordingly.

But, you'd think they woulda PUT TONE ADJUST INTO THE BITMAP CLASS?????



Still, for anything large, this code does take some time to change a bitmap.  If I could adjust the bitmap with the Tone class I could with sprites, it would be dang near instantaneous.  Unfortunately, I need something FAAAAST!

And no. You cannot tone adjust a sprite and copy the contents into a bitmap.  The sprite's own properties are what is adjusted, not the bitmap contained within.

So, does anyone know of a faster means to adjust the tone of a bitmap?
Up is down, left is right and sideways is straight ahead. - Cord "Circle of Iron", 1978 (written by Bruce Lee and James Coburn... really...)
[Image: QrnbKlx.jpg]
[Image: sGz1ErF.png] [Image: liM4ikn.png] [Image: fdzKgZA.png] [Image: sj0H81z.png]
[Image: QL7oRau.png] [Image: uSqjY09.png] [Image: GAA3qE9.png] [Image: 2Hmnx1G.png] [Image: BwtNdKw.png%5B]
Above are clickable links

Reply }


Messages In This Thread
Possible means to speed up Bitmap TONE code? - by DerVVulfman - 06-10-2023, 01:10 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
   Permanently modifying move speed Keeroh 5 8,613 05-24-2017, 05:47 AM
Last Post: DerVVulfman
   Meagan's Particles' speed Raou 6 8,277 04-01-2015, 03:43 PM
Last Post: Raou
   Custom Game_Event code lags too much! MechanicalPen 4 5,901 06-27-2013, 11:22 PM
Last Post: MechanicalPen
   Ruby, RGSS & General Code Discussion Kain Nobel 6 9,940 12-22-2012, 05:11 AM
Last Post: MechanicalPen
   Getting bitmap width and height of leading party member? PK8 5 7,685 08-27-2012, 11:41 AM
Last Post: Kain Nobel
   Pixelmovement and speed ark 2 5,044 05-31-2010, 05:51 PM
Last Post: ark
   VX Show Picture Event Command Code? PK8 2 5,844 02-27-2009, 11:30 PM
Last Post: PK8



Users browsing this thread: