Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Additional Bitmap Methods

[rgss]#==============================================================================
# ** Additional Bitmap Methods
#------------------------------------------------------------------------------
#   By Untra and Glitchfinder
#   5/29/10
#   v0.85
#==============================================================================
class Bitmap
#------------------------------------------------------------------------------
#Make sure you have uabm.dll in your project folder.
#You can get it from (assuming link is not dead):
#http://www.box.net/shared/9m54d8hkzu
#------------------------------------------------------------------------------
  Brighten = Win32API.new("uabm.dll", "Brighten", "li", "v")
  Darken = Win32API.new("uabm.dll", "Darken", "li", "v")
  Invert = Win32API.new("uabm.dll", "Invert", "l", "v")
  Grayscale = Win32API.new("uabm.dll", "Grayscale", "l", "v")
  #--------------------------------------------------------------------------
  # * Brighten
  #--------------------------------------------------------------------------
  def brighten(amount)
    Brighten.call(self.__id__, amount)
  end
  #--------------------------------------------------------------------------
  # * Darken
  #--------------------------------------------------------------------------
  def darken(amount)
    Darken.call(self.__id__, amount)
  end
  #--------------------------------------------------------------------------
  # * Invert
  #--------------------------------------------------------------------------
  def invert
    Invert.call(self.__id__)
  end
  #--------------------------------------------------------------------------
  # * Grayscale
  #--------------------------------------------------------------------------
   def grayscale
      Grayscale.call(self.__id__)
   end
end
 
#==============================================================================
# * Edit by Silver Wind
#==============================================================================
class Game_Event
 
  def name
    return @event.name
  end
 
end
#-------------------------------------------------------------------------#
class Game_Map
  def get_event(key)
     if key.is_a?(String)
      return get_event_by_name(key)
    else
      return get_event_by_id(key)
    end
  end
 
  def get_event_by_name(name)
    for i in @map.events.keys
      ev = @events
      return ev if ev.name == name
    end
    # Error: No such event
    return nil
  end
 
  def get_event_by_id(i)
    for k in @map.events.keys
      ev = @events[k]
      return ev if ev.id== i
    end
    # Error: No such event
    return nil
  end
end
#-------------------------------------------------------------------------#
class Scene_Map
 
  def bitmap_effect(event, action, amount=nil)
    ev = $game_map.get_event(event)
    sprite = @spriteset.get_sprite(ev)
    return if ev.nil?
    case (action)
    when 'brighten'
      sprite.brighten_by(amount)
    when 'darken'
      sprite.darken_by(amount)
    when 'invert'
      sprite.invert
    when 'grayscale'
      sprite.grayscale
    end
  end
 
end
#-------------------------------------------------------------------------#
class Spriteset_Map
 
  def get_sprite(event)
    for sprite in @character_sprites
      ev = sprite.character
      # if it's the same Game_Event object.
      if ev.object_id == event.object_id  
        target_sprite = sprite
      end
    end
    return target_sprite
  end
 
end
#-------------------------------------------------------------------------#
class Sprite_Character < RPG::Sprite
  def brighten_by(x)
    self.bitmap.brighten(x)
  end
 
  def darken_by(x)
    self.bitmap.darken(x)
  end
 
  def invert
    self.bitmap.invert
  end
 
  def grayscale
    self.bitmap.grayscale
  end
 
  def update
    super
    # If tile ID, file name, or hue are different from current ones
    if @tile_id != @character.tile_id or
       @character_name != @character.character_name or
       @character_hue != @character.character_hue
      # Remember tile ID, file name, and hue
      @tile_id = @character.tile_id
      @character_name = @character.character_name
      @character_hue = @character.character_hue
      # If tile ID value is valid
      if @tile_id >= 384
        #----------------------------- edit -----------------------------#
        # clone the bitmap before using it for an event.
        bitmap = RPG::Cache.tile($game_map.tileset_name,
          @tile_id, @character.character_hue)
        self.bitmap = bitmap.clone
        #----------------------------------------------------------------#
        self.src_rect.set(0, 0, 32, 32)
        self.ox = 16
        self.oy = 32
      # If tile ID value is invalid
      else
        #----------------------------- edit -----------------------------#
        # clone the bitmap before using it for an event.
        bitmap = RPG::Cache.character(@character.character_name,
          @character.character_hue)
        self.bitmap = bitmap.clone
        #----------------------------------------------------------------#
        @cw = bitmap.width / 4
        @ch = bitmap.height / 4
        self.ox = @cw / 2
        self.oy = @ch
      end
    end
    # Set visible situation
    self.visible = (not @character.transparent)
    # If graphic is character
    if @tile_id == 0
      # Set rectangular transfer
      sx = @character.pattern * @cw
      sy = (@character.direction - 2) / 2 * @ch
      self.src_rect.set(sx, sy, @cw, @ch)
    end
    # Set sprite coordinates
    self.x = @character.screen_x
    self.y = @character.screen_y
    self.z = @character.screen_z(@ch)
    # Set opacity level, blend method, and bush depth
    self.opacity = @character.opacity
    self.blend_type = @character.blend_type
    self.bush_depth = @character.bush_depth
    # Animation
    if @character.animation_id != 0
      animation = $data_animations[@character.animation_id]
      animation(animation, true)
      @character.animation_id = 0
    end
  end
 
end
#-------------------------------------------------------------------------#
 
def brighten(event,amount)
  #return unless $scene.is_a?(Scene_Map)
  $scene.bitmap_effect(event,'brighten',amount)
end
 
def darken(event,amount)
  $scene.bitmap_effect(event,'darken',amount)
end
 
def invert(event)
  $scene.bitmap_effect(event,'invert')
end
 
def grayscale(event)
  $scene.bitmap_effect(event,'grayscale')
end
[/rgss]
Tiny edit. only 170 lines o.o;
The 4 last methods are meant to keep the call short in the script box.
Send the event name or number as parameter:
brighten("EV001",64)
invert(2)
 
Silver Wind, were you aware that any methods or variables defined within the Interpreter class (Or Game_Interpreter for VX) will be accessible to the evented "call script..." command? That means that you would only have to define those methods inside the interpreter, instead of making them globally accessible. Another thing to note is that the Interpreter has a neat little method called get_character(parameter), that will return $game_player if the parameter is -1, or the event that called it, if it is 0, or, even better, will return the event whose ID you gave it as a parameter, if the parameter is above 0. This makes it extraordinarily easy to modify events on the fly. Another thing to note is that you never want to use the variable @index in the "call script..." command, because that is used to determine where in the event's command list you are operating from, and will result in an infinitely looping event, or, even worse, a crash. (You can define instance variables with @variable_name that will be accessible by future call scripts, if you want to.)
 

Untra

Sponsor

aanndd... I'm stuck.
Code:
 

//Pixelate

extern "C" _declspec (dllexport) BOOL Pixelate(long object, int size)

{

    RGSSBMINFO *bitmap = ((RGSSBITMAP*) (object<<1)) -> bm -> bminfo;

    DWORD rowsize;

    DWORD width, height;

    LPBYTE row;

    long x, y, z;

    int red, green, blue, alpha;

    if(!bitmap) return false;

    if(size <= 1) return false;

    width = bitmap -> infoheader -> biWidth;

    height = bitmap -> infoheader -> biHeight;

    rowsize = width * 4;

    row = (LPBYTE) (bitmap -> firstRow);

    for ( y = 0; y < (int) height - 1 / size; y++) {

        y *= size;

        for ( x = 0; x < (int) width - 1 / size; x++) {

            x *= size;

            red, green, blue, alpha = 0;

            LPBYTE thisrow = row;

            for ( z = 0; z == size; z++){

                //row

                thisrow = row;

                red += (thisrow[2]);

                green += (thisrow[1]);

                blue += (thisrow[0]);

                alpha += (thisrow[3]);

                //row

                x += z;

                thisrow = row;

                red += (thisrow[2]);

                green += (thisrow[1]);

                blue += (thisrow[0]);

                alpha += (thisrow[3]);

                x -= z;

                //row your boat

                y += z;

                thisrow = row;

                red += (thisrow[2]);

                green += (thisrow[1]);

                blue += (thisrow[0]);

                alpha += (thisrow[3]);

                y -= z;

            }

            double block = size;

            double r = red / pow(block,2);

            r *=  sqrt(block);

            double g = green / pow(block,2);

            g *=  sqrt(block);

            double b = blue / pow(block,2);

            b *=  sqrt(block);

            double a = alpha / pow(block,2);

            a *=  sqrt(block);

 

            if(r > 255) r = 255;

            if(g > 255) g = 255;

            if(b > 255) b = 255;

            if(a > 255) a = 255;

            if(r < 0) r = 0;

            if(g < 0) g = 0;

            if(b < 0) b = 0;

            if(a < 0) a = 0;

            thisrow[2] = (BYTE) r;

            thisrow[1] = (BYTE) g;

            thisrow[0] = (BYTE) b;

            thisrow[3] = (BYTE) a;

            thisrow += 4;

        }

        row -= rowsize;

    }

    return true;

}

 
I think I'm completely off by line 25 there. This would be a lot easier with a set_pixel function :sad:
Edit: Sudden realization the original RGSS Method would be useful for comparison:
Code:
   def pixelate(size)

     if size <= 1

       return nil

     else

       for w in 0..((width - 1) / size)

         w *= size

         for h in 0..((height - 1) / size)

            h *= size

            r, g, b, a = 0, 0, 0, 0

            size.times do |i|

               color = get_pixel(w, h)

               r += color.red ; g += color.green ; b += color.blue ; a += color.alpha

               color = get_pixel(w + i, h)

               r += color.red ; g += color.green ; b += color.blue ; a += color.alpha

               color = get_pixel(w, h + i)

               r += color.red ; g += color.green ; b += color.blue ; a += color.alpha

            end

            fill_rect(w, h, size, size, Color.new( (r / size**2) * Math.sqrt(size), (g / size**2) * Math.sqrt(size), (b / size**2) * Math.sqrt(size), (a / size**2) * Math.sqrt(size)))

          end

        end

     end

   end
 
I think you're in need of some more source code. Here's the full source code of my .dll file, from the last time I updated it. At the time, I was working on adding in all the effects from theory's Character Shaders. Go ahead and add effects from that to your project, since all of them were open source or unsourced ruby code that has been floating around foreign-language RM* communities for years.

C++:
<span style="color: #339900;">#include <cstdlib>

<span style="color: #339900;">#include <ctime>

<span style="color: #339900;">#include <ctype.h>

<span style="color: #339900;">#include <math.h>

<span style="color: #339900;">#include <stddef.h>

<span style="color: #339900;">#include <stdio.h>

<span style="color: #339900;">#include <stdlib.h>

<span style="color: #339900;">#include <string.h>

<span style="color: #339900;">#include <windows.h>

 

BOOL APIENTRY DllMain( HMODULE hModule, DWORD  ul_reason_for_call, LPVOID lpReserved) {

    switch (ul_reason_for_call) {

        case DLL_PROCESS_ATTACH:

        case DLL_THREAD_ATTACH:

        case DLL_THREAD_DETACH:

        case DLL_PROCESS_DETACH:

        break;

    }

    return true;

}

 

typedef struct {

    DWORD flags;

    DWORD klass;

    void (*dmark) (void*);

    void (*dfree) (void*);

    double *data; //red is index 1, green is index 2, blue 3, alpha 0

} RGSSCOLOR;

 

typedef struct{

    DWORD unk1;

    DWORD unk2;

    BITMAPINFOHEADER *infoheader;

    RGSSCOLOR *firstRow;

    RGBQUAD *lastRow;

} RGSSBMINFO;

 

typedef struct{

    DWORD unk1;

    DWORD unk2;

    RGSSBMINFO *bminfo;

} BITMAPSTRUCT;

 

typedef struct{

    DWORD flags;

    DWORD klass;

    void (*dmark) (void*);

    void (*dfree) (void*);

    BITMAPSTRUCT *bm;

} RGSSBITMAP;

 

<span style="color: #339900;">#define ASSERT(x) if(!x){DebugOut("Failed: %s: %d", #x, __LINE__);}

 

extern <span style="color: #666666;">"C" _declspec (dllexport) BOOL AlienTwo(long object){

    RGSSBMINFO *bitmap = ((RGSSBITMAP*) (object<<<span style="color: #0000dd;">1)) -> bm -> bminfo;

    DWORD rowsize;

    DWORD width, height;

    LPBYTE row, pixel1, pixel2, pixel3, pixel4;

    long x, y;

    double red, green, blue;

    if(!bitmap) return false;

    width = bitmap -> infoheader -> biWidth;

    height = bitmap -> infoheader -> biHeight;

    rowsize = width * <span style="color: #0000dd;">4;

    row = (LPBYTE) (bitmap -> firstRow);

    for ( y = <span style="color: #0000dd;">0; y < (int) height; y++) {

        pixel1 = row;

        pixel2 = row;

        pixel3 = row;

        pixel4 = row;

        if((y >= <span style="color: #0000dd;">0) && ((y + <span style="color: #0000dd;">1) < (int) height)) {

            pixel2 -= rowsize;

            pixel3 -= rowsize;

        }

        for ( x = <span style="color: #0000dd;">0; x < (int) width; x++) {

            if(((y + <span style="color: #0000dd;">1) < (int) height) && ((x + <span style="color: #0000dd;">1) < (int) width)) {

                pixel2 += <span style="color: #0000dd;">4;

                pixel4 += <span style="color: #0000dd;">4;

                red = <span style="color: #0000dd;">sqrt(<span style="color: #0000dd;">pow(((double) pixel1[<span style="color: #0000dd;">2] - pixel2[<span style="color: #0000dd;">2]), <span style="color: #0000dd;">2) + <span style="color: #0000dd;">pow(((double) pixel3[<span style="color: #0000dd;">2] - pixel4[<span style="color: #0000dd;">2]), <span style="color: #0000dd;">2));

                green = <span style="color: #0000dd;">sqrt(<span style="color: #0000dd;">pow(((double) pixel1[<span style="color: #0000dd;">1] - pixel2[<span style="color: #0000dd;">1]), <span style="color: #0000dd;">2) + <span style="color: #0000dd;">pow(((double) pixel3[<span style="color: #0000dd;">1] - pixel4[<span style="color: #0000dd;">1]), <span style="color: #0000dd;">2));

                blue = <span style="color: #0000dd;">sqrt(<span style="color: #0000dd;">pow(((double) pixel1[<span style="color: #0000dd;">0] - pixel2[<span style="color: #0000dd;">0]), <span style="color: #0000dd;">2) + <span style="color: #0000dd;">pow(((double) pixel3[<span style="color: #0000dd;">0] - pixel4[<span style="color: #0000dd;">0]), <span style="color: #0000dd;">2));

            }

            else if(((y + <span style="color: #0000dd;">1) >= (int) height) && ((x + <span style="color: #0000dd;">1) < (int) width)) {

                pixel2 += <span style="color: #0000dd;">4;

                pixel4 += <span style="color: #0000dd;">4;

                red = <span style="color: #0000dd;">sqrt(<span style="color: #0000dd;">pow((double) pixel1[<span style="color: #0000dd;">2], <span style="color: #0000dd;">2) + <span style="color: #0000dd;">pow((double) pixel4[<span style="color: #0000dd;">2], <span style="color: #0000dd;">2));

                green = <span style="color: #0000dd;">sqrt(<span style="color: #0000dd;">pow((double) pixel1[<span style="color: #0000dd;">1], <span style="color: #0000dd;">2) + <span style="color: #0000dd;">pow((double) pixel4[<span style="color: #0000dd;">1], <span style="color: #0000dd;">2));

                blue = <span style="color: #0000dd;">sqrt(<span style="color: #0000dd;">pow((double) pixel1[<span style="color: #0000dd;">0], <span style="color: #0000dd;">2) + <span style="color: #0000dd;">pow((double) pixel4[<span style="color: #0000dd;">0], <span style="color: #0000dd;">2));

            }

            else if(((y + <span style="color: #0000dd;">1) < (int) height) && ((x + <span style="color: #0000dd;">1) >= (int) width)) {

                red = <span style="color: #0000dd;">sqrt(<span style="color: #0000dd;">pow((double) pixel1[<span style="color: #0000dd;">2], <span style="color: #0000dd;">2) + <span style="color: #0000dd;">pow((double) pixel3[<span style="color: #0000dd;">2], <span style="color: #0000dd;">2));

                green = <span style="color: #0000dd;">sqrt(<span style="color: #0000dd;">pow((double) pixel1[<span style="color: #0000dd;">1], <span style="color: #0000dd;">2) + <span style="color: #0000dd;">pow((double) pixel3[<span style="color: #0000dd;">1], <span style="color: #0000dd;">2));

                blue = <span style="color: #0000dd;">sqrt(<span style="color: #0000dd;">pow((double) pixel1[<span style="color: #0000dd;">0], <span style="color: #0000dd;">2) + <span style="color: #0000dd;">pow((double) pixel3[<span style="color: #0000dd;">0], <span style="color: #0000dd;">2));

            }

            else {

                red = pixel1[<span style="color: #0000dd;">2];

                green = pixel1[<span style="color: #0000dd;">1];

                blue = pixel1[<span style="color: #0000dd;">0];

            }

            if((red + green + blue) > (double) <span style="color: #0000dd;">60) {

                if((red >= green) && (red >= blue)) {

                    red += <span style="color: #0000dd;">20;

                }

                else if((green >= red) && (green >= blue)) {

                    green += <span style="color: #0000dd;">20;

                }

                else {

                    blue += <span style="color: #0000dd;">20;

                }

                if(red > <span style="color: #0000dd;">255) red = <span style="color: #0000dd;">255;

                if(green > <span style="color: #0000dd;">255) green = <span style="color: #0000dd;">255;

                if(blue > <span style="color: #0000dd;">255) blue = <span style="color: #0000dd;">255;

                pixel1[<span style="color: #0000dd;">2] = (BYTE) red;

                pixel1[<span style="color: #0000dd;">1] = (BYTE) green;

                pixel1[<span style="color: #0000dd;">0] = (BYTE) blue;

            }

            else {

                pixel1[<span style="color: #0000dd;">2] = <span style="color: #0000dd;">0;

                pixel1[<span style="color: #0000dd;">1] = <span style="color: #0000dd;">0;

                pixel1[<span style="color: #0000dd;">0] = <span style="color: #0000dd;">0;

            }

            pixel1 += <span style="color: #0000dd;">4;

            pixel3 += <span style="color: #0000dd;">4;

        }

        row -= rowsize;

    }

    return true;

}

 

extern <span style="color: #666666;">"C" _declspec (dllexport) BOOL BlackAndWhite(long object){

    RGSSBMINFO *bitmap = ((RGSSBITMAP*) (object<<<span style="color: #0000dd;">1)) -> bm -> bminfo;

    DWORD rowsize;

    DWORD width, height;

    LPBYTE row;

    long x, y;

    int shade;

    if(!bitmap) return false;

    width = bitmap -> infoheader -> biWidth;

    height = bitmap -> infoheader -> biHeight;

    rowsize = width * <span style="color: #0000dd;">4;

    row = (LPBYTE) (bitmap -> firstRow);

    for ( y = <span style="color: #0000dd;">0; y < (int) height; y++) {

        LPBYTE thisrow = row;

        for ( x = <span style="color: #0000dd;">0; x < (int) width; x++) {

            shade = ((thisrow[<span style="color: #0000dd;">2] + thisrow[<span style="color: #0000dd;">1] + thisrow[<span style="color: #0000dd;">0]) / <span style="color: #0000dd;">3);

            thisrow[<span style="color: #0000dd;">2] = shade;

            thisrow[<span style="color: #0000dd;">1] = shade;

            thisrow[<span style="color: #0000dd;">0] = shade;

            thisrow += <span style="color: #0000dd;">4;

        }

        row -= rowsize;

    }

    return true;

}

 

extern <span style="color: #666666;">"C" _declspec (dllexport) BOOL BlackAndWhite2(long object){

    RGSSBMINFO *bitmap = ((RGSSBITMAP*) (object<<<span style="color: #0000dd;">1)) -> bm -> bminfo;

    DWORD rowsize;

    DWORD width, height;

    LPBYTE row;

    long x, y;

    int red, green, blue, shade;

    if(!bitmap) return false;

    width = bitmap -> infoheader -> biWidth;

    height = bitmap -> infoheader -> biHeight;

    rowsize = width * <span style="color: #0000dd;">4;

    row = (LPBYTE)(bitmap -> firstRow);

    for ( y = <span style="color: #0000dd;">0; y < (int) height; y++) {

        LPBYTE thisrow = row;

        for ( x = <span style="color: #0000dd;">0; x < (int) width; x++) {

            red = (thisrow[<span style="color: #0000dd;">1] - thisrow[<span style="color: #0000dd;">0] + thisrow[<span style="color: #0000dd;">1] + thisrow[<span style="color: #0000dd;">2]);

            red = (red * thisrow[<span style="color: #0000dd;">2] / <span style="color: #0000dd;">256);

            if(red > <span style="color: #0000dd;">255) red = <span style="color: #0000dd;">255;

            green = (thisrow[<span style="color: #0000dd;">0] - thisrow[<span style="color: #0000dd;">1] + thisrow[<span style="color: #0000dd;">0] + thisrow[<span style="color: #0000dd;">2]);

            green = (green * thisrow[<span style="color: #0000dd;">1] / <span style="color: #0000dd;">256);

            if(green > <span style="color: #0000dd;">255) green = <span style="color: #0000dd;">255;

            blue = (thisrow[<span style="color: #0000dd;">0] - thisrow[<span style="color: #0000dd;">1] + thisrow[<span style="color: #0000dd;">0] + thisrow[<span style="color: #0000dd;">2]);

            blue = (blue * thisrow[<span style="color: #0000dd;">0] / <span style="color: #0000dd;">256);

            if(blue > <span style="color: #0000dd;">255) blue = <span style="color: #0000dd;">255;

            shade = ((red + green + blue) / <span style="color: #0000dd;">3);

            thisrow[<span style="color: #0000dd;">2] = shade;

            thisrow[<span style="color: #0000dd;">1] = shade;

            thisrow[<span style="color: #0000dd;">0] = shade;

            thisrow += <span style="color: #0000dd;">4;

        }

        row -= rowsize;

    }

    return true;

}

 

extern <span style="color: #666666;">"C" _declspec (dllexport) BOOL Emboss(long object){

    RGSSBMINFO *bitmap = ((RGSSBITMAP*) (object<<<span style="color: #0000dd;">1)) -> bm -> bminfo;

    DWORD rowsize;

    DWORD width, height;

    LPBYTE row;

    long x, y;

    int red, green, blue;

    if(!bitmap) return false;

    width = bitmap -> infoheader -> biWidth;

    height = bitmap -> infoheader -> biHeight;

    rowsize = width * <span style="color: #0000dd;">4;

    row = (LPBYTE)(bitmap -> firstRow);

    for ( y = <span style="color: #0000dd;">0; y < (int) height; y++) {

        LPBYTE thisrow = row;

        LPBYTE nextrow = row;

        if((y > <span style="color: #0000dd;">0) && ((y + <span style="color: #0000dd;">1) < (int) height)) {

            nextrow -= (width * <span style="color: #0000dd;">4);

        }

        for ( x = <span style="color: #0000dd;">0; x < (int) width; x++) {

            if(((y + <span style="color: #0000dd;">1) < (int) height) && ((x + <span style="color: #0000dd;">1) < (int) width)) {

                nextrow += <span style="color: #0000dd;">4;

                red = (thisrow[<span style="color: #0000dd;">2] - nextrow[<span style="color: #0000dd;">2] + <span style="color: #0000dd;">128);

                green = (thisrow[<span style="color: #0000dd;">1] - nextrow[<span style="color: #0000dd;">1] + <span style="color: #0000dd;">128);

                blue = (thisrow[<span style="color: #0000dd;">0] - nextrow[<span style="color: #0000dd;">0] + <span style="color: #0000dd;">128);

            }

            else {

                red = (thisrow[<span style="color: #0000dd;">2] + <span style="color: #0000dd;">128);

                green = (thisrow[<span style="color: #0000dd;">1] + <span style="color: #0000dd;">128);

                blue = (thisrow[<span style="color: #0000dd;">0] + <span style="color: #0000dd;">128);

            }

            red = <span style="color: #0000dd;">abs(red);

            green = <span style="color: #0000dd;">abs(green);

            blue = <span style="color: #0000dd;">abs(blue);

            if(red > <span style="color: #0000dd;">255) red = <span style="color: #0000dd;">255;

            if(green > <span style="color: #0000dd;">255) green = <span style="color: #0000dd;">255;

            if(blue > <span style="color: #0000dd;">255) blue = <span style="color: #0000dd;">255;

            thisrow[<span style="color: #0000dd;">2] = red;

            thisrow[<span style="color: #0000dd;">1] = green;

            thisrow[<span style="color: #0000dd;">0] = blue;

            thisrow += <span style="color: #0000dd;">4;

        }

        row -= rowsize;

    }

    return true;

}

 

extern <span style="color: #666666;">"C" _declspec (dllexport) BOOL MinusTwo(long object){

    RGSSBMINFO *bitmap = ((RGSSBITMAP*) (object<<<span style="color: #0000dd;">1)) -> bm -> bminfo;

    DWORD rowsize;

    DWORD width, height;

    LPBYTE row;

    long x, y;

    double color1, color2;

    if(!bitmap) return false;

    width = bitmap -> infoheader -> biWidth;

    height = bitmap -> infoheader -> biHeight;

    rowsize = width * <span style="color: #0000dd;">4;

    row = (LPBYTE)(bitmap -> firstRow);

    for ( y = <span style="color: #0000dd;">0; y < (int) height; y++) {

        LPBYTE thisrow = row;

        LPBYTE nextrow = row;

        if((y > <span style="color: #0000dd;">0) && ((y + <span style="color: #0000dd;">1) < (int) height)) {

            nextrow -= (width * <span style="color: #0000dd;">4);

        }

        for ( x = <span style="color: #0000dd;">0; x < (int) width; x++) {

            if(((y + <span style="color: #0000dd;">1) < (int) height) && ((x + <span style="color: #0000dd;">1) < (int) width)) {

                nextrow += <span style="color: #0000dd;">4;

                color2 = (((nextrow[<span style="color: #0000dd;">2] * <span style="color: #0000dd;">0.3) + (nextrow[<span style="color: #0000dd;">1] * <span style="color: #0000dd;">0.6) + (nextrow[<span style="color: #0000dd;">0] * <span style="color: #0000dd;">0.1)) / <span style="color: #0000dd;">10);

            }

            else {

                color2 = <span style="color: #0000dd;">0;

            }

            color1 = (((thisrow[<span style="color: #0000dd;">2] * <span style="color: #0000dd;">0.3) + (thisrow[<span style="color: #0000dd;">1] * <span style="color: #0000dd;">0.6) + (thisrow[<span style="color: #0000dd;">0] * <span style="color: #0000dd;">0.1)) / <span style="color: #0000dd;">10);

            if((color1 - color2) > <span style="color: #0000dd;">0.2) {

                thisrow[<span style="color: #0000dd;">2] = <span style="color: #0000dd;">0;

                thisrow[<span style="color: #0000dd;">1] = <span style="color: #0000dd;">0;

                thisrow[<span style="color: #0000dd;">0] = <span style="color: #0000dd;">0;

            }

            else {

                thisrow[<span style="color: #0000dd;">2] = <span style="color: #0000dd;">255;

                thisrow[<span style="color: #0000dd;">1] = <span style="color: #0000dd;">255;

                thisrow[<span style="color: #0000dd;">0] = <span style="color: #0000dd;">255;

            }

            thisrow += <span style="color: #0000dd;">4;

        }

        row -= rowsize;

    }

    return true;

}

 

extern <span style="color: #666666;">"C" _declspec (dllexport) BOOL Sepia(long object){

    RGSSBMINFO *bitmap = ((RGSSBITMAP*) (object<<<span style="color: #0000dd;">1)) -> bm -> bminfo;

    DWORD rowsize;

    DWORD width, height;

    LPBYTE row;

    long x, y;

    double red, green, blue;

    if(!bitmap) return false;

    width = bitmap -> infoheader -> biWidth;

    height = bitmap -> infoheader -> biHeight;

    rowsize = width * <span style="color: #0000dd;">4;

    row = (LPBYTE)(bitmap -> firstRow);

    for ( y = <span style="color: #0000dd;">0; y < (int) height; y++) {

        LPBYTE thisrow = row;

        for ( x = <span style="color: #0000dd;">0; x < (int) width; x++) {

            red = ((thisrow[<span style="color: #0000dd;">2] * <span style="color: #0000dd;">0.393) + (thisrow[<span style="color: #0000dd;">1] * <span style="color: #0000dd;">0.769) + (thisrow[<span style="color: #0000dd;">0] * <span style="color: #0000dd;">0.189));

            green = ((thisrow[<span style="color: #0000dd;">2] * <span style="color: #0000dd;">0.349) + (thisrow[<span style="color: #0000dd;">1] * <span style="color: #0000dd;">0.686) + (thisrow[<span style="color: #0000dd;">0] * <span style="color: #0000dd;">0.168));

            blue = ((thisrow[<span style="color: #0000dd;">2] * <span style="color: #0000dd;">0.272) + (thisrow[<span style="color: #0000dd;">1] * <span style="color: #0000dd;">0.534) + (thisrow[<span style="color: #0000dd;">0] * <span style="color: #0000dd;">0.131));

            if(red > <span style="color: #0000dd;">255) red = <span style="color: #0000dd;">255;

            if(green > <span style="color: #0000dd;">255) green = <span style="color: #0000dd;">255;

            if(blue > <span style="color: #0000dd;">255) blue = <span style="color: #0000dd;">255;

            thisrow[<span style="color: #0000dd;">2] = (BYTE) red;

            thisrow[<span style="color: #0000dd;">1] = (BYTE) green;

            thisrow[<span style="color: #0000dd;">0] = (BYTE) blue;

            thisrow += <span style="color: #0000dd;">4;

        }

        row -= rowsize;

    }

    return true;

}

 

extern <span style="color: #666666;">"C" _declspec (dllexport) BOOL Sharpen(long object){

    RGSSBMINFO *bitmap = ((RGSSBITMAP*) (object<<<span style="color: #0000dd;">1)) -> bm -> bminfo;

    DWORD rowsize;

    DWORD width, height;

    LPBYTE row;

    long x, y;

    double red, green, blue, ap;

    if(!bitmap) return false;

    width = bitmap -> infoheader -> biWidth;

    height = bitmap -> infoheader -> biHeight;

    rowsize = width * <span style="color: #0000dd;">4;

    row = (LPBYTE)(bitmap -> firstRow);

    red = <span style="color: #0000dd;">0;

    green = <span style="color: #0000dd;">0;

    blue = <span style="color: #0000dd;">0;

    ap = <span style="color: #0000dd;">0.8;

    for ( y = <span style="color: #0000dd;">0; y < (int) height; y++) {

        LPBYTE thisrow = row;

        LPBYTE nextrow = row;

        if((y > <span style="color: #0000dd;">0) && ((y + <span style="color: #0000dd;">1) < (int) height)) {

            nextrow -= (width * <span style="color: #0000dd;">4);

        }

        for ( x = <span style="color: #0000dd;">0; x < (int) width; x++) {

            if(((y + <span style="color: #0000dd;">1) < (int) height) && ((x + <span style="color: #0000dd;">1) < (int) width)) {

                nextrow += <span style="color: #0000dd;">4;

                red += nextrow[<span style="color: #0000dd;">2];

                green += nextrow[<span style="color: #0000dd;">1];

                blue += nextrow[<span style="color: #0000dd;">0];

            }

            red = (((thisrow[<span style="color: #0000dd;">2] - (red / <span style="color: #0000dd;">3)) * ap) + thisrow[<span style="color: #0000dd;">2]);

            green = (((thisrow[<span style="color: #0000dd;">1] - (green / <span style="color: #0000dd;">3)) * ap) + thisrow[<span style="color: #0000dd;">1]);

            blue = (((thisrow[<span style="color: #0000dd;">0] - (blue / <span style="color: #0000dd;">3)) * ap) + thisrow[<span style="color: #0000dd;">0]);

            if(red > <span style="color: #0000dd;">255) red = <span style="color: #0000dd;">255;

            if(green > <span style="color: #0000dd;">255) green = <span style="color: #0000dd;">255;

            if(blue > <span style="color: #0000dd;">255) blue = <span style="color: #0000dd;">255;

            if(red < <span style="color: #0000dd;">0) red = <span style="color: #0000dd;">0;

            if(green < <span style="color: #0000dd;">0) green = <span style="color: #0000dd;">0;

            if(blue < <span style="color: #0000dd;">0) blue = <span style="color: #0000dd;">0;

            thisrow[<span style="color: #0000dd;">2] = (BYTE) red;

            thisrow[<span style="color: #0000dd;">1] = (BYTE) green;

            thisrow[<span style="color: #0000dd;">0] = (BYTE) blue;

            thisrow += <span style="color: #0000dd;">4;

        }

        row -= rowsize;

    }

    return true;

}

 

extern <span style="color: #666666;">"C" _declspec (dllexport) BOOL Soften(long object){

    RGSSBMINFO *bitmap = ((RGSSBITMAP*) (object<<<span style="color: #0000dd;">1)) -> bm -> bminfo;

    DWORD rowsize;

    DWORD width, height;

    LPBYTE row;

    long x, y, xoffset, yoffset;

    int red, green, blue;

    if(!bitmap) return false;

    width = bitmap -> infoheader -> biWidth;

    height = bitmap -> infoheader -> biHeight;

    rowsize = width * <span style="color: #0000dd;">4;

    row = (LPBYTE) (bitmap -> firstRow);

    for ( y = <span style="color: #0000dd;">0; y < (int) height; y++) {

        LPBYTE thisrow = row;

        for ( x = <span style="color: #0000dd;">0; x < (int) width; x++) {

            red = <span style="color: #0000dd;">0;

            green = <span style="color: #0000dd;">0;

            blue = <span style="color: #0000dd;">0;

            for ( xoffset = <span style="color: #0000dd;">-1; xoffset <= <span style="color: #0000dd;">1; xoffset++) {

                for ( yoffset = <span style="color: #0000dd;">-1; yoffset <= <span style="color: #0000dd;">1; yoffset++) {

                    if ((y > <span style="color: #0000dd;">0) && ((y + yoffset) < (int) height) && ((y + yoffset) > <span style="color: #0000dd;">0) && ((x + xoffset) > <span style="color: #0000dd;">0) && ((x + xoffset) < (int) width)) {

                        LPBYTE newrow = thisrow;

                        newrow -= (yoffset * (width * <span style="color: #0000dd;">4));

                        newrow += (xoffset * <span style="color: #0000dd;">4);

                        red += newrow[<span style="color: #0000dd;">2];

                        green += newrow[<span style="color: #0000dd;">1];

                        blue += newrow[<span style="color: #0000dd;">0];

                    }

                }

            }

            red /= <span style="color: #0000dd;">9;

            green /= <span style="color: #0000dd;">9;

            blue /= <span style="color: #0000dd;">9;

            thisrow[<span style="color: #0000dd;">2] = red;

            thisrow[<span style="color: #0000dd;">1] = green;

            thisrow[<span style="color: #0000dd;">0] = blue;

            thisrow += <span style="color: #0000dd;">4;

        }

        row -= rowsize;

    }

    return true;

}

 

extern <span style="color: #666666;">"C" _declspec (dllexport) BOOL Splatter(long object){

    RGSSBMINFO *bitmap = ((RGSSBITMAP*) (object<<<span style="color: #0000dd;">1)) -> bm -> bminfo;

    DWORD rowsize;

    DWORD width, height;

    LPBYTE row;

    long x, y;

    int randomx, randomy;

    if(!bitmap) return false;

    width = bitmap -> infoheader -> biWidth;

    height = bitmap -> infoheader -> biHeight;

    rowsize = width * <span style="color: #0000dd;">4;

    row = (LPBYTE) (bitmap -> firstRow);

    <span style="color: #0000dd;">srand((unsigned)<span style="color: #0000dd;">time(<span style="color: #0000dd;">0));

    for ( y = <span style="color: #0000dd;">0; y < (int) height; y++) {

        LPBYTE thisrow = row;

        for ( x = <span style="color: #0000dd;">0; x < (int) width; x++) {

            randomx = ((<span style="color: #0000dd;">rand() % <span style="color: #0000dd;">3) + <span style="color: #0000dd;">1);

            randomy = ((<span style="color: #0000dd;">rand() % <span style="color: #0000dd;">3) + <span style="color: #0000dd;">1);

            if((y > <span style="color: #0000dd;">0) && ((y + randomy) < (int) height) && ((x + randomx) < (int) width)) {

                LPBYTE newrow = thisrow;

                newrow -= (randomy * (width * <span style="color: #0000dd;">4));

                newrow += (randomx * <span style="color: #0000dd;">4);

                thisrow[<span style="color: #0000dd;">2] = newrow[<span style="color: #0000dd;">2];

                thisrow[<span style="color: #0000dd;">1] = newrow[<span style="color: #0000dd;">1];

                thisrow[<span style="color: #0000dd;">0] = newrow[<span style="color: #0000dd;">0];

                thisrow[<span style="color: #0000dd;">3] = newrow[<span style="color: #0000dd;">3];

            }

            else {

                thisrow[<span style="color: #0000dd;">2] = <span style="color: #0000dd;">0;

                thisrow[<span style="color: #0000dd;">1] = <span style="color: #0000dd;">0;

                thisrow[<span style="color: #0000dd;">0] = <span style="color: #0000dd;">0;

                thisrow[<span style="color: #0000dd;">3] = <span style="color: #0000dd;">0;

            }

            thisrow += <span style="color: #0000dd;">4;

        }

        row -= rowsize;

    }

    return true;

}

 

extern <span style="color: #666666;">"C" _declspec (dllexport) BOOL Swap(long object1, long object2, int index){

    RGSSBMINFO *bitmap = ((RGSSBITMAP*) (object1<<<span style="color: #0000dd;">1)) -> bm -> bminfo;

    RGSSBMINFO *palette = ((RGSSBITMAP*) (object2<<<span style="color: #0000dd;">1)) -> bm -> bminfo;

    DWORD rowsize, pRowSize;

    DWORD width, height, pWidth;

    LPBYTE row, originalColor, newColor;

    long x, y;

    int red, green, blue, oldRed, oldGreen, oldBlue;

    if(!bitmap) return false;

    width = bitmap -> infoheader -> biWidth;

    height = bitmap -> infoheader -> biHeight;

    pWidth = palette -> infoheader -> biWidth;

    rowsize = width * <span style="color: #0000dd;">4;

    pRowSize = pWidth * <span style="color: #0000dd;">4;

    row = (LPBYTE) (bitmap -> firstRow);

    for ( y = <span style="color: #0000dd;">0; y < (int) height; y++) {

        LPBYTE thisrow = row;

        for ( x = <span style="color: #0000dd;">0; x < (int) width; x++) {

            red = thisrow[<span style="color: #0000dd;">2];

            green = thisrow[<span style="color: #0000dd;">1];

            blue = thisrow[<span style="color: #0000dd;">0];

            originalColor = (LPBYTE) (palette -> firstRow);

            for ( int i = <span style="color: #0000dd;">0; i < (int) pWidth; i++) {

                oldRed = originalColor[<span style="color: #0000dd;">2];

                oldGreen = originalColor[<span style="color: #0000dd;">1];

                oldBlue = originalColor[<span style="color: #0000dd;">0];

                if ( (red == oldRed) && (green == oldGreen) && (blue == oldBlue)) {

                    newColor = originalColor - (pRowSize * (index + <span style="color: #0000dd;">1));

                    thisrow[<span style="color: #0000dd;">2] = newColor[<span style="color: #0000dd;">2];

                    thisrow[<span style="color: #0000dd;">1] = newColor[<span style="color: #0000dd;">1];

                    thisrow[<span style="color: #0000dd;">0] = newColor[<span style="color: #0000dd;">0];

                }

                originalColor += <span style="color: #0000dd;">4;

                newColor += <span style="color: #0000dd;">4;

            }

            thisrow += <span style="color: #0000dd;">4;

        }

        row -= rowsize;

    }

    return true;

}

 

extern <span style="color: #666666;">"C" _declspec (dllexport) BOOL Blank(long object){

    RGSSBMINFO *bitmap = ((RGSSBITMAP*) (object<<<span style="color: #0000dd;">1)) -> bm -> bminfo;

    DWORD rowsize;

    DWORD width, height;

    LPBYTE row;

    long x, y;

    int red, green, blue;

    if(!bitmap) return false;

    width = bitmap -> infoheader -> biWidth;

    height = bitmap -> infoheader -> biHeight;

    rowsize = width * <span style="color: #0000dd;">4;

    row = (LPBYTE) (bitmap -> firstRow);

    for ( y = <span style="color: #0000dd;">0; y < (int) height; y++) {

        LPBYTE thisrow = row;

        for ( x = <span style="color: #0000dd;">0; x < (int) width; x++) {

            red = thisrow[<span style="color: #0000dd;">2];

            green = thisrow[<span style="color: #0000dd;">1];

            blue = thisrow[<span style="color: #0000dd;">0];

            thisrow += <span style="color: #0000dd;">4;

        }

        row -= rowsize;

    }

    return true;

}
 

Untra

Sponsor

I've been playing around with these methods, and I'm astounded! All of them work excellently. In particular, I like the splatter method; its code is actually the frost method, making things a ton easier. I'll incorporate all of these into the .dll and release them.

Oh, thank you so much! :biggrin:
 

Untra

Sponsor

Update: New version out now!
Version v0.9
http://www.box.net/shared/9m54d8hkzu

Code:
#==============================================================================

# ** Additional Bitmap Methods

#------------------------------------------------------------------------------

#   By Untra and Glitchfinder

#   6/3/10

#   v0.9

#==============================================================================

class Bitmap

#------------------------------------------------------------------------------

#Make sure you have uabm.dll in your project folder.

#You can get it from (assuming link is not dead):

#http://www.box.net/shared/9m54d8hkzu

#------------------------------------------------------------------------------

  Brighten = Win32API.new("uabm.dll", "Brighten", "li", "v")

  Darken = Win32API.new("uabm.dll", "Darken", "li", "v")

  Invert = Win32API.new("uabm.dll", "Invert", "l", "v")

  Grayscale = Win32API.new("uabm.dll", "Grayscale", "l", "v")

  Hcontrast = Win32API.new("uabm.dll", "Hcontrast", "l", "v")

  Monochrome = Win32API.new("uabm.dll", "Monochrome", "l", "v")

  Emboss = Win32API.new("uabm.dll", "Emboss", "l", "v")

  Sepia = Win32API.new("uabm.dll", "Sepia", "l", "v")

  Sharpen = Win32API.new("uabm.dll", "Sharpen", "l", "v")

  Soften = Win32API.new("uabm.dll", "Soften", "l", "v")

  #--------------------------------------------------------------------------

  # * Brighten (0...255)

  #--------------------------------------------------------------------------

  def brighten(amount)

    Brighten.call(self.__id__, amount)

  end

  #--------------------------------------------------------------------------

  # * Darken (0...255)

  #--------------------------------------------------------------------------

  def darken(amount)

    Darken.call(self.__id__, amount)

  end

  #--------------------------------------------------------------------------

  # * Invert

  #--------------------------------------------------------------------------

  def invert

    Invert.call(self.__id__)

  end

  #--------------------------------------------------------------------------

  # * Grayscale

  #--------------------------------------------------------------------------

  def grayscale

    Grayscale.call(self.__id__)

  end

  #--------------------------------------------------------------------------

  # * Hyper Contrast

  #--------------------------------------------------------------------------

  def hyper_contrast

    Hcontrast.call(self.__id__)

  end

  #--------------------------------------------------------------------------

  # * Monochrome

  #--------------------------------------------------------------------------

  def monochrome

    Monochrome.call(self.__id__)

  end

  #--------------------------------------------------------------------------

  # * Emboss {buggy}

  #--------------------------------------------------------------------------

  def emboss

    Emboss.call(self.__id__)

  end

  #--------------------------------------------------------------------------

  # * Sepia

  #--------------------------------------------------------------------------

  def sepia

    Sepia.call(self.__id__)

  end

  #--------------------------------------------------------------------------

  # * Sharpen {will update with numeric value options}

  #--------------------------------------------------------------------------

  def sharpen

    Sharpen.call(self.__id__)

  end

  #--------------------------------------------------------------------------

  # * Soften {will update with numeric value options}

  #--------------------------------------------------------------------------

  def soften

    Soften.call(self.__id__)

  end

end

As for the methods, most of them have been added in, but all of them could certainly use some tweaking. I'm hoping to apply arguments to the Sharpen and Soften methods, and the Sepia looks fairly off (it looks more like its been dipped in a bath of urine than sodium sulfide). I'm still working with the Frost to get it to work more accurately. For some reason, pixels that get pushed off the left side of the bitmap by the frosting wind up on the right, while pixels pushed to the right are simply lost.
test.png
scattered to 24
It only becomes really noticeable with smaller bitmaps at higher passes. The answer will come to me, but for now its a strange quirk thats been bothering me.
 
I thought that, since I provided you with some of the methods, I might as well go a bit further. Here is a more permanent link for the current version of the .dll file. You might also want to try hosting it at bb.ohsk.net, which is hosted by shadow, owner of the Slacked IRC network.

Also, what in particular do you mean when you say that the emboss doesn't get every color. When I tested it, it seemed to work fine. I could be wrong, though. Also, below is the original set of Ruby methods that I was basing this stuff on:

Ruby:
def self.shader_alien2

    for y in 0..@bitmap.height

      for x in 0..@bitmap.width

          pixel1 = @bitmap.get_pixel(x, y)

          pixel2 = @bitmap.get_pixel(x + 1, y + 1)

          pixel3 = @bitmap.get_pixel(x, y + 1)

          pixel4 = @bitmap.get_pixel(x + 1, y)

          red = Math.hypot((pixel1.red - pixel2.red),

            (pixel3.red - pixel4.red))

          green = Math.hypot((pixel1.green - pixel2.green),

            (pixel3.green - pixel4.green))

          blue = Math.hypot((pixel1.blue - pixel2.blue),

            (pixel3.blue - pixel4.blue))

          if (red + green + blue) > 60

            if [red, green, blue].max == red

              @bitmap.set_pixel(x, y, Color.new(red + 20, green, blue,

                pixel1.alpha))

            elsif [red, green, blue].max == green

              @bitmap.set_pixel(x, y, Color.new(red, green + 20, blue,

                pixel1.alpha))

            elsif [red, green, blue].max == blue

              @bitmap.set_pixel(x, y, Color.new(red, green, blue + 20,

                pixel1.alpha))

            end

          else

            @bitmap.set_pixel(x, y, Color.new(0, 0, 0, pixel1.alpha))

          end

      end

      if x % 640 == 0 and x != 0

         self.contents.blt(0, 0, @bitmap, @bitmap.rect)

         Graphics.update

      end

    end

    return @bitmap

  end

 

  def self.shader_bnw

    for y in 0..@bitmap.height

      for x in 0..@bitmap.width

          a = @bitmap.get_pixel(x, y)

          shade = ((a.red + a.green + a.blue) / 3)

          @bitmap.set_pixel(x, y, Color.new(shade, shade, shade, a.alpha))

      end

      if x % 640 == 0 and x != 0

         self.contents.blt(0, 0, @bitmap, @bitmap.rect)

         Graphics.update

      end

    end

    return @bitmap

  end

 

  def self.shader_emboss

    for y in 0..@bitmap.height

      for x in 0..@bitmap.width

        a = @bitmap.get_pixel(x, y)

        b = @bitmap.get_pixel(x + 1, y + 1)

        red = (a.red - b.red + 128)

        red = red.abs

        green = (a.green - b.green + 128)

        green = green.abs

        blue = (a.blue - b.blue + 128)

        blue = blue.abs

        red = 255 if red > 255

        green = 255 if green > 255

        blue = 255 if blue > 255

        @bitmap.set_pixel(x, y, Color.new(red, green, blue, a.alpha))

      end

      if x % 640 == 0 and x != 0

         self.contents.blt(0, 0, @bitmap, @bitmap.rect)

         Graphics.update

      end

    end

    return @bitmap

  end

 

  def self.shader_minustwo

    for y in 0..@bitmap.height

      for x in 0..@bitmap.width

          a = @bitmap.get_pixel(x, y)

          b = @bitmap.get_pixel(x + 1, y + 1)

          color1 = (((a.red * 0.3) + (a.green * 0.6) + (a.blue * 0.1)) / 10)

          color2 = (((b.red * 0.3) + (b.green * 0.6) + (b.blue * 0.1)) / 10)

          if (color1 - color2) > 0.2

            @bitmap.set_pixel(x, y, Color.new(0, 0, 0, a.alpha))

          else

            @bitmap.set_pixel(x, y, Color.new(255, 255, 255, a.alpha))

          end

      end

      if x % 640 == 0 and x != 0

         self.contents.blt(0, 0, @bitmap, @bitmap.rect)

         Graphics.update

      end

    end

    return @bitmap

  end

 

  def self.shader_sepia

    for y in 0..@bitmap.height

      for x in 0..@bitmap.width

          a = @bitmap.get_pixel(x, y)

          red = ((a.red * 0.393) + (a.green * 0.769) + (a.blue * 0.189))

          green = ((a.red * 0.349) + (a.green * 0.686) + (a.blue * 0.168))

          blue = ((a.red * 0.272) + (a.green * 0.534) + (a.blue * 0.131))

          p blue if (y == 0 and x == 0)

          red = 255 if red > 255

          green = 255 if green > 255

          blue = 255 if blue > 255

          @bitmap.set_pixel(x, y, Color.new(red, green, blue, a.alpha))

      end

      if x % 640 == 0 and x != 0

         self.contents.blt(0, 0, @bitmap, @bitmap.rect)

         Graphics.update

      end

    end

    return @bitmap

  end

 

  def self.shader_sharpen

    red = 0

    green = 0

    blue = 0

    ap = 0.8

    for y in 0..@bitmap.height

      for x in 0..@bitmap.width

        a = @bitmap.get_pixel(x + 1, y + 1)

        b = @bitmap.get_pixel(x, y)

        red += a.red

        green += a.green

        blue += a.blue

        red = (b.red - (red / 3)) * ap + b.red

        green = (b.green - (green / 3)) * ap + b.green

        blue =(b.blue - (blue / 3)) * ap + b.blue

        red = 255 if red > 255

        green = 255 if green > 255

        blue = 255 if blue > 255

        red = 0 if red < 0

        green = 0 if green < 0

        blue = 0 if blue < 0

        @bitmap.set_pixel(x, y, Color.new(red, green, blue, b.alpha))

      end

      if x % 640 == 0 and x != 0

         self.contents.blt(0, 0, @bitmap, @bitmap.rect)

         Graphics.update

      end

    end

    return @bitmap

  end 

 

  def self.shader_soften

    for y in 0..@bitmap.height

      for x in 0..@bitmap.width

        red = 0

        green = 0

        blue = 0

        for x_offset in -1..1

          for y_offset in -1..1

            a = @bitmap.get_pixel(x + x_offset, y + y_offset)

            red += a.red

            green += a.green

            blue += a.blue

          end

        end

        red /= 9

        green /= 9

        blue /= 9

        b = @bitmap.get_pixel(x, y)

        @bitmap.set_pixel(x, y, Color.new(red, green, blue, b.alpha))

      end

      if x % 640 == 0 and x != 0

         self.contents.blt(0, 0, @bitmap, @bitmap.rect)

         Graphics.update

      end

    end

    return @bitmap

  end

 

  def self.shader_splatter

    for y in 0..@bitmap.height

      for x in 0..@bitmap.width

        x_offset = rand(3) + 1

        y_offset = rand(3) + 1

        b = @bitmap.get_pixel(x + x_offset, y + y_offset)

        @bitmap.set_pixel(x, y, Color.new(b.red, b.green, b.blue, b.alpha))

      end

      if x % 640 == 0 and x != 0

         self.contents.blt(0, 0, @bitmap, @bitmap.rect)

         Graphics.update

      end

    end

    return @bitmap

  end

 

  

  

  

  def self.shader_contrast

    conre = 1 ; ligre = 20

    congr = 2 ; liggr = 20

    conbl = 1 ; ligbl = 20

    ligre =(ligre-127*(conre-1))

    liggr =(liggr-127*(congr-1))

    ligbl =(ligbl-127*(conbl-1))

    for i in 0..@bitmap.height

      for j in 0..@bitmap.width

          a = @bitmap.get_pixel(j,i)

          re = a.red*conre + ligre

          gr = a.green*congr + liggr

          bl = a.blue*conbl + ligbl

          re = 255 if re > 255 ; re = 0 if re < 0

          gr = 255 if gr > 255 ; gr = 0 if gr < 0

          bl = 255 if bl > 255 ; bl = 0 if bl < 0

          @bitmap.set_pixel(j,i,Color.new(re, gr, bl, a.alpha))

      end

      if j % 640 == 0 and j != 0

         self.contents.blt(0,0,@bitmap,@bitmap.rect)

         Graphics.update

      end

    end

    return @bitmap

  end

 

  def self.shader_negative

    conre = -2 ; ligre = 0

    congr = -2 ; liggr = 0

    conbl = -2 ; ligbl = 0

    ligre =(ligre-127*(conre-1))

    liggr =(liggr-127*(congr-1))

    ligbl =(ligbl-127*(conbl-1))

    for i in 0..@bitmap.height

      for j in 0..@bitmap.width

          a = @bitmap.get_pixel(j,i)

          re = a.red*conre + ligre

          gr = a.green*congr + liggr

          bl = a.blue*conbl + ligbl

          re = 255 if re > 255 ; re = 0 if re < 0

          gr = 255 if gr > 255 ; gr = 0 if gr < 0

          bl = 255 if bl > 255 ; bl = 0 if bl < 0

          @bitmap.set_pixel(j,i,Color.new(re, gr, bl, a.alpha))

      end

      if j % 640 == 0 and j != 0

         self.contents.blt(0,0,@bitmap,@bitmap.rect)

         Graphics.update

      end

    end

    return @bitmap

  end

 

  def self.shader_cartoon

    for i in 0..@bitmap.height

      for j in 0..@bitmap.width

          a = @bitmap.get_pixel(j,i)

          b = @bitmap.get_pixel(j,i)

          re = a.red+b.red

          gr = a.green+b.green

          bl = a.blue+b.blue

          re = 255 if re > 255 ; re = 0 if re < 0

          gr = 255 if gr > 255 ; gr = 0 if gr < 0

          bl = 255 if bl > 255 ; bl = 0 if bl < 0

          @bitmap.set_pixel(j,i,Color.new(re, gr, bl, a.alpha))

      end

      if j % 640 == 0 and j != 0

         self.contents.blt(0,0,@bitmap,@bitmap.rect)

         Graphics.update

      end

    end

    return @bitmap

  end

 

  def self.shader_bright

    ra = 50

    for i in 0..@bitmap.height

      for j in 0..@bitmap.width

          a = @bitmap.get_pixel(j,i)

          b = @bitmap.get_pixel(j,i)

          re = (a.red>b.red ? a.red : b.red)

          gr = (a.green>b.green ? a.green : b.green)

          bl = (a.blue>b.blue ? a.blue : b.blue)

          al = (a.alpha>b.alpha ? a.alpha : b.alpha)

          @bitmap.set_pixel(j,i,Color.new(re+ra, gr+ra, bl+ra, al))

      end

      if j % 640 == 0 and j != 0

         self.contents.blt(0,0,@bitmap,@bitmap.rect)

         Graphics.update

      end

    end

    return @bitmap

  end

 

  def self.shader_bizarro

    ra = 100

    wh = 50

    for i in 0..@bitmap.height

      for j in 0..@bitmap.width

          a = @bitmap.get_pixel(j,i)

          no = rand(ra)-ra+1

          re = a.red+no+wh ; gr = a.green+no+wh ; bl = a.blue+no+wh

          re = 255 if re > 255 ; re = 0 if re < 0

          gr = 255 if gr > 255 ; gr = 0 if gr < 0

          bl = 255 if bl > 255 ; bl = 0 if bl < 0

          @bitmap.set_pixel(j,i,Color.new(re, gr, bl, a.alpha))

      end

      if j % 640 == 0 and j != 0

         self.contents.blt(0,0,@bitmap,@bitmap.rect)

         Graphics.update

      end

    end

    return @bitmap

  end

 

  def self.shader_bulletholes

    ra = 10

    for i in 0..@bitmap.height

      for j in 0..@bitmap.width

          a = @bitmap.get_pixel(j,i)

          if rand(101) < ra

             re = rand(256) ; gr = rand(256) ; bl = rand(256)

             @bitmap.set_pixel(j,i,Color.new(re, gr, bl, a.alpha))

          end

      end

      if j % 640 == 0 and j != 0

         self.contents.blt(0,0,@bitmap,@bitmap.rect)

         Graphics.update

      end

    end

    return @bitmap

  end

 

  def self.shader_sill

    ra = 500

    re = 0 ; gr = 0 ; bl = 0

    for i in 1..(@bitmap.height-1)

      for j in 1..(@bitmap.width-1)

        for m in -1..1

          for n in -1..1

            if m != 0 and n != 0

              a = @bitmap.get_pixel(j+m,i+n)

              re = re + a.red

              gr = gr + a.green

              bl = bl + a.blue

            end

          end

        end

        b = @bitmap.get_pixel(j,i)

        re = (b.red-re/8).abs

        gr = (b.green-gr/8).abs

        bl = (b.blue-bl/8).abs

        if (re+gr+bl) > ra

          @bitmap.set_pixel(j,i,Color.new(255, 255, 255, b.alpha))

        else

          @bitmap.set_pixel(j,i,Color.new(0, 0, 0, b.alpha))

        end

      end

      if j % 639 == 0 and j != 0

         self.contents.blt(0,0,@bitmap,@bitmap.rect)

         Graphics.update

      end

    end

    return @bitmap

  end

 

  def self.shader_bw2

    for i in 0..@bitmap.height

      for j in 0..@bitmap.width

          a = @bitmap.get_pixel(j,i)

          re = (a.green-a.blue+a.green+a.red).abs

          re = re*a.red/256

          re = 255 if re > 255

          gr = (a.blue-a.green+a.blue+a.red).abs

          gr = gr*a.red/256

          gr = 255 if gr > 255

          bl = (a.blue-a.green+a.blue+a.red).abs

          bl = bl*a.green/256

          bl = 255 if bl > 255

          ma = (re+gr+bl)/3

          @bitmap.set_pixel(j,i,Color.new(ma, ma, ma, a.alpha))

      end

      if j % 640 == 0 and j != 0

         self.contents.blt(0,0,@bitmap,@bitmap.rect)

         Graphics.update

      end

    end

    return @bitmap

  end

 

  def self.shader_alien

    for i in 0..@bitmap.height

      for j in 0..@bitmap.width

          a = @bitmap.get_pixel(j,i)

          re = (a.green-a.blue)**2/128

          re = 255 if re > 255

          gr = (a.red-a.blue)**2/128

          gr = 255 if gr > 255

          bl = (a.red-a.green)**2/128

          bl = 255 if bl > 255

          @bitmap.set_pixel(j,i,Color.new(re, gr, bl, a.alpha))

      end

      if j % 640 == 0 and j != 0

         self.contents.blt(0,0,@bitmap,@bitmap.rect)

         Graphics.update

      end

    end

    return @bitmap

  end

 

  def self.shader_monotone

    ccr = 255

    ccg = 255

    ccb = 50

    for i in 0..@bitmap.height

      for j in 0..@bitmap.width

          a = @bitmap.get_pixel(j,i)

          ma = (a.red+a.green+a.blue)/3

          re = ma*ccr/255

          gr = ma*ccg/255

          bl = ma*ccb/255

          @bitmap.set_pixel(j,i,Color.new(re, gr, bl, a.alpha))

      end

      if j % 640 == 0 and j != 0

         self.contents.blt(0,0,@bitmap,@bitmap.rect)

         Graphics.update

      end

    end

    return @bitmap

  end

 

  def self.shader_enhance

    for i in 0..@bitmap.height

      for j in 0..@bitmap.width

          a = @bitmap.get_pixel(j,i)

          re = a.red**2/255

          gr = a.green**2/255

          bl = a.blue**2/255

          @bitmap.set_pixel(j,i,Color.new(re, gr, bl, a.alpha))

      end

      if j % 640 == 0 and j != 0

         self.contents.blt(0,0,@bitmap,@bitmap.rect)

         Graphics.update

      end

    end

    return @bitmap

  end

  

  def self.shader_undead

    for i in 0..@bitmap.height

      for j in 0..@bitmap.width

          a = @bitmap.get_pixel(j,i)

          re = a.green*a.blue/255

          gr = a.red*a.blue/255

          bl = a.red*a.green/255

          @bitmap.set_pixel(j,i,Color.new(re, gr, bl, a.alpha))

      end

      if j % 640 == 0 and j != 0

         self.contents.blt(0,0,@bitmap,@bitmap.rect)

         Graphics.update

      end

    end

    return @bitmap

  end

  

  def self.shader_wtf

    for i in 0..@bitmap.height

      for j in 0..@bitmap.width

          a = @bitmap.get_pixel(j,i)

          re = Math.sin(Math.atan2(a.green, a.blue))*255

          gr = Math.sin(Math.atan2(a.blue, a.red))*255

          bl = Math.sin(Math.atan2(a.red, a.green))*255

          @bitmap.set_pixel(j,i,Color.new(re, gr, bl, a.alpha))

      end

      if j % 640 == 0 and j != 0

         self.contents.blt(0,0,@bitmap,@bitmap.rect)

         Graphics.update

      end

    end

    return @bitmap

  end

 

  def self.shader_plexiglass

    pow = 200

    lig_x = @bitmap.width/2

    lig_y = @bitmap.height/2

    rr = Math.hypot(lig_x,lig_y)

    rc = rr**2

    for i in 0..@bitmap.height

      for j in 0..@bitmap.width

          a = @bitmap.get_pixel(j,i)

          len = (j-lig_x)**2+(i-lig_y)**2

          if len < rc

             dis = Math.sqrt(len);

             bri = pow*(rr-dis)/rr

             re = a.red+bri

             gr = a.green+bri

             bl = a.blue+bri

             al = a.alpha+bri

             re = 255 if re > 255

             gr = 255 if gr > 255

             bl = 255 if bl > 255

             al = 255 if al > 255

             @bitmap.set_pixel(j,i,Color.new(re, gr, bl, al))

           end

      end

      if j % 640 == 0 and j != 0

         self.contents.blt(0,0,@bitmap,@bitmap.rect)

         Graphics.update

      end

    end

    return @bitmap

  end

As a final note, your "Hyper Emboss" filter is looking very similar to Photoshop's "Glowing Edges" filter.
 

Untra

Sponsor

Frost is giving me fits. It works perfectly in terms of scattering the pixels, but it simultaneously wraps pixels that get pushed from the top or left edges of the bitmap to the bottom and right sides. It also starts to lag with larger images (even at one pass) which makes me think the code is a bit chunky. Heres a good example of what I mean:
test-1.png

frosted to 24
I'll post the code to frost if you want to take a look at it. In the meantime, I'm going to take another whack at pixelate.
Code:
extern "C" _declspec (dllexport) BOOL Frost(long object, int passes){

    RGSSBMINFO *bitmap = ((RGSSBITMAP*) (object<<1)) -> bm -> bminfo;

    DWORD rowsize;

    DWORD width, height;

    LPBYTE row;

    long x, y, z;

    int randomx, randomy;

    if(!bitmap) return false;

    width = bitmap -> infoheader -> biWidth;

    height = bitmap -> infoheader -> biHeight;

    rowsize = width * 4;

    row = (LPBYTE) (bitmap -> firstRow);

    //srand((unsigned)time(0));

    for ( y = 0; y < (int) height; y++) {

        LPBYTE thisrow = row;

        for ( x = 0; x < (int) width; x++) {

            randomx = 0;

            randomy = 0;

            //Summate the random, so as to avoid repeating the whole process for each pass.

            //LPBYTE newrow = thisrow;

            for ( z = 0; z <= passes - 2; z++) {

                randomx += ((rand() % - 5) + 2);

            }

            for ( z = 0; z <= passes - 2; z++) {

                randomy += ((rand() % - 5) + 2);

            }

            if((y > 0) && ((y + randomy) < (int) height) && ((x + randomx) < (int) width)) {

                LPBYTE newrow = thisrow;

                newrow -= (randomy * (width * 4));

                newrow += (randomx * 4 );

                thisrow[2] = newrow[2];

                thisrow[1] = newrow[1];

                thisrow[0] = newrow[0];

                thisrow[3] = newrow[3];

            }

            else {

                thisrow[2] = 0;

                thisrow[1] = 0;

                thisrow[0] = 0;

                thisrow[3] = 0;

            }

            thisrow += 4;

        }

        row -= rowsize;

    }

    return true;

}

As for the emboss, I thought an embossed image had to be devoid of colors. The emboss method leaves some colors behind. It should be a easy fix though; just loop through the pixels a second time and put them into grayscale or monochrome.
 

Untra

Sponsor

Code:
//Pixelate #2

extern "C" _declspec (dllexport) BOOL Pixelate(long object, int size)

{

    RGSSBMINFO *bitmap = ((RGSSBITMAP*) (object<<1)) -> bm -> bminfo;

    DWORD rowsize;

    DWORD width, height;

    LPBYTE row, scana, scanb, scanc, reset;

    long x, y, w, h, z, wx, wy; 

    int red, green, blue, alpha;

    if(!bitmap) return false;

    if(size <= 1) return false;

    red = 0;

    green = 0;

    blue = 0;

    alpha = 0;

    width = bitmap -> infoheader -> biWidth;

    height = bitmap -> infoheader -> biHeight;

    rowsize = (width * 4);

    row = (LPBYTE) (bitmap -> firstRow);

    reset = row;

    scana = row;

    scanb = row;

    scanc = row;

    double block = size;

    for ( y = 0; y < (int) ((height - 1) / size); y++) 

    {

        LPBYTE thisrow = row;

        h = y;

        h *= size;

        for ( x = 0; x < (int) ((width - 1) / size); x++) 

        {

            w = x;

            w *= size;

            red, green, blue, alpha = 0;

            for ( z = 0; z == size - 1; z++)

            {

                scana = reset;

                scana += (4 * w);

                scana -= (rowsize * h);

                scanb = reset;

                scanb += (4 * (w + z));

                scanb -= (rowsize * h);

                scanc = reset;

                scanc += (4 * w);

                scanc -= (rowsize * (h + z));

                red += ( scana[2] + scanb[2] + scanc[2] );

                green += ( scana[1] + scanb[1] + scanc[1] );

                blue += ( scana[0] + scanb[0] + scanc[0] );

                alpha += ( scana[3] + scanb[3] + scanc[3] );

            }

            red /= pow(block,2);

            green /= pow(block,2);

            blue /= pow(block,2);

            alpha /= pow(block,2);

            red *= sqrt(block);

            green *= sqrt(block);

            blue *= sqrt(block);

            alpha *= sqrt(block);

            for (wy = 0; wy == (size - 1); wy++);

            {   

                for (wx = 0; wx == (size - 1); wx++);

                {

                    thisrow[2] = (BYTE) red;

                    thisrow[1] = (BYTE) green;

                    thisrow[0] = (BYTE) blue;

                    thisrow[3] = (BYTE) alpha; 

                    thisrow += 4;

                }

                thisrow -= (width * 4);

            }

            thisrow += (4);

        }

        thisrow -= (rowsize);

    }

    return true;

}
Code:
 

extern "C" _declspec (dllexport) BOOL Pixelate(long object, int size)

{

    RGSSBMINFO *bitmap = ((RGSSBITMAP*) (object<<1)) -> bm -> bminfo;

    DWORD rowsize;

    DWORD width, height;

    LPBYTE row;

    long x, y, zx, zy, wx, wy; 

    int red, green, blue, alpha;

    if(!bitmap) return false;

    if(size <= 1) return false;

    red = 0;

    green = 0;

    blue = 0;

    alpha = 0;

    width = bitmap -> infoheader -> biWidth;

    height = bitmap -> infoheader -> biHeight;

    rowsize = (width * 4 * size);

    row = (LPBYTE) (bitmap -> firstRow);

    for ( y = 0; y < (int) ((height - 1) / size); y++) 

    {

        LPBYTE thisrow = row;

        for ( x = 0; x < (int) ((width - 1) / size); x++) 

        {

            red, green, blue, alpha = 0;

            for ( zy = 0; zy == size - 1; zy++)

            {

                LPBYTE scanrow = thisrow;

                for ( zx = 0; zx == size - 1; zx++)

                {

                    red += (scanrow[2]);

                    green += (scanrow[1]);

                    blue += (scanrow[0]);

                    alpha += (scanrow[3]);

                    scanrow += 4;

                }

                scanrow += (4 * width);

            }

            double block = size;

            double r = red / pow(block,2);

            r *=  sqrt(block);

            double g = green / pow(block,2);

            g *=  sqrt(block);

            double b = blue / pow(block,2);

            b *=  sqrt(block);

            double a = alpha / pow(block,2);

            a *=  sqrt(block);

            LPBYTE saverow = thisrow;

            for (wy = 0; wy == (size - 1); wy++);

            {   

                for (wx = 0; wx == (size - 1); wx++);

                {

                    thisrow[2] = (BYTE) r;

                    thisrow[1] = (BYTE) g;

                    thisrow[0] = (BYTE) b;

                    thisrow[3] = (BYTE) a; 

                    thisrow += 4;

                }

                thisrow -= (width * 4);

            }

            thisrow = saverow;

            thisrow += (4 * size) ;

        }

        thisrow -= (rowsize);

    }

    return true;

}

 

I'm just about ready to punch a kitten.

I did fix Sepia though. The result looks a lot better.
new:
11a.png

old:
11.png

code:
Code:
extern "C" _declspec (dllexport) BOOL Sepia(long object){

    RGSSBMINFO *bitmap = ((RGSSBITMAP*) (object<<1)) -> bm -> bminfo;

    DWORD rowsize;

    DWORD width, height;

    LPBYTE row;

    long x, y;

    double red, green, blue, avg;

    if(!bitmap) return false;

    width = bitmap -> infoheader -> biWidth;

    height = bitmap -> infoheader -> biHeight;

    rowsize = width * 4;

    row = (LPBYTE)(bitmap -> firstRow);

    for ( y = 0; y < (int) height; y++) {

        LPBYTE thisrow = row;

        for ( x = 0; x < (int) width; x++) {

            avg = (thisrow[2] + thisrow[1] + thisrow[0]) / 3;

            red = (((thisrow[2] * 0.740) + (thisrow[1] * 0.475) + (thisrow[0] * 0.225)) + avg) / 2;

            green = (((thisrow[2] * 0.565) + (thisrow[1] * 0.335) + (thisrow[0] * 0.180)) + avg) / 2;

            blue = (((thisrow[2] * 0.325) + (thisrow[1] * 0.278) + (thisrow[0] * 0.110)) + avg) / 2;

            if(red > 255) red = 255;

            if(green > 255) green = 255;

            if(blue > 255) blue = 255;

            thisrow[2] = (BYTE) red;

            thisrow[1] = (BYTE) green;

            thisrow[0] = (BYTE) blue;

            thisrow += 4;

        }

        row -= rowsize;

    }

    return true;

}

Edit: The full source right now:
Code:
#include <stdafx.h>

#include <cstdlib>

#include <ctime>

#include <ctype.h>

#include <math.h>

#include <stddef.h>

#include <stdio.h>

#include <stdlib.h>

#include <string.h>

#include <windows.h>

 

 

 

typedef struct{

    DWORD flags;

    DWORD klass;

    void (*dmark)(void*);

    void (*dfree)(void*);

    double *data;

} RGSSCOLOR;

 

typedef struct{

    DWORD unk1;

    DWORD unk2;

    BITMAPINFOHEADER *infoheader;

    RGSSCOLOR *firstRow; //RGBQUAD *firstRow;

    RGBQUAD *lastRow;

} RGSSBMINFO;

 

typedef struct{

    DWORD unk1;

    DWORD unk2;

    RGSSBMINFO *bminfo;

} BITMAPSTRUCT;

 

typedef struct{

    DWORD flags;

    DWORD klass;

    void (*dmark)(void*);

    void (*dfree)(void*);

    BITMAPSTRUCT *bm;

} RGSSBITMAP;

 

#define ASSERT(x) if(!x){DebugOut("Failed: %s: %d", #x, __LINE__);}

 

//Brighten

extern "C" _declspec (dllexport) BOOL Brighten(long object, int amount)

{

    RGSSBMINFO *bitmap = ((RGSSBITMAP*) (object<<1)) -> bm -> bminfo;

    DWORD rowsize;

    DWORD width, height;

    LPBYTE row;

    long x, y;

    int red, green, blue;

    if(!bitmap) return false;

    width = bitmap -> infoheader -> biWidth;

    height = bitmap -> infoheader -> biHeight;

    rowsize = width * 4;

    row = (LPBYTE) (bitmap -> firstRow);

    for ( y = 0; y < (int) height; y++) {

        LPBYTE thisrow = row;

        for ( x = 0; x < (int) width; x++) {

            red = (thisrow[2] + amount);

            green = (thisrow[1] + amount);

            blue = (thisrow[0] + amount);

            if(red > 255) red = 255;

            if(green > 255) green = 255;

            if(blue > 255) blue = 255;

            thisrow[2] = (BYTE) red;

            thisrow[1] = (BYTE) green;

            thisrow[0] = (BYTE) blue;

            thisrow += 4;

        }

        row -= rowsize;

    }

    return true;

}

 

//Darken

extern "C" _declspec (dllexport) BOOL Darken(long object, int amount)

{

    RGSSBMINFO *bitmap = ((RGSSBITMAP*) (object<<1)) -> bm -> bminfo;

    DWORD rowsize;

    DWORD width, height;

    LPBYTE row;

    long x, y;

    int red, green, blue;

    if(!bitmap) return false;

    width = bitmap -> infoheader -> biWidth;

    height = bitmap -> infoheader -> biHeight;

    rowsize = width * 4;

    row = (LPBYTE) (bitmap -> firstRow);

    for ( y = 0; y < (int) height; y++) {

        LPBYTE thisrow = row;

        for ( x = 0; x < (int) width; x++) {

            red = (thisrow[2] - amount);

            green = (thisrow[1] - amount);

            blue = (thisrow[0] - amount);

            if(red < 0) red = 0;

            if(green < 0) green = 0;

            if(blue < 0) blue = 0;

            thisrow[2] = (BYTE) red;

            thisrow[1] = (BYTE) green;

            thisrow[0] = (BYTE) blue;

            thisrow += 4;

        }

        row -= rowsize;

    }

    return true;

}

 

//Invert

extern "C" _declspec (dllexport) BOOL Invert(long object)

{

    RGSSBMINFO *bitmap = ((RGSSBITMAP*) (object<<1)) -> bm -> bminfo;

    DWORD rowsize;

    DWORD width, height;

    LPBYTE row;

    long x, y;

    int red, green, blue;

    if(!bitmap) return false;

    width = bitmap -> infoheader -> biWidth;

    height = bitmap -> infoheader -> biHeight;

    rowsize = width * 4;

    row = (LPBYTE) (bitmap -> firstRow);

    for ( y = 0; y < (int) height; y++) {

        LPBYTE thisrow = row;

        for ( x = 0; x < (int) width; x++) {

            red = (255 - thisrow[2]);

            green = (255 - thisrow[1]);

            blue = (255 - thisrow[0]);

            thisrow[2] = (BYTE) red;

            thisrow[1] = (BYTE) green;

            thisrow[0] = (BYTE) blue;

            thisrow += 4;

        }

        row -= rowsize;

    }

    return true;

}

 

//Grayscale

extern "C" _declspec (dllexport) BOOL Grayscale(long object)

{

    RGSSBMINFO *bitmap = ((RGSSBITMAP*) (object<<1)) -> bm -> bminfo;

    DWORD rowsize;

    DWORD width, height;

    LPBYTE row;

    long x, y;

    int red, green, blue, color;

    if(!bitmap) return false;

    width = bitmap -> infoheader -> biWidth;

    height = bitmap -> infoheader -> biHeight;

    rowsize = width * 4;

    row = (LPBYTE) (bitmap -> firstRow);

    for ( y = 0; y < (int) height; y++) {

        LPBYTE thisrow = row;

        for ( x = 0; x < (int) width; x++) {

            color = (thisrow[2] + thisrow[1] + thisrow[0]) / 3;

            red = color;

            green = color;

            blue = color;

            if(red < 0) red = 0;

            if(green < 0) green = 0;

            if(blue < 0) blue = 0;

            thisrow[2] = (BYTE) red;

            thisrow[1] = (BYTE) green;

            thisrow[0] = (BYTE) blue;

            thisrow += 4;

        }

        row -= rowsize;

    }

    return true;

}

 

//Hyper Contrast

extern "C" _declspec (dllexport) BOOL Hcontrast(long object){

    RGSSBMINFO *bitmap = ((RGSSBITMAP*) (object<<1)) -> bm -> bminfo;

    DWORD rowsize;

    DWORD width, height;

    LPBYTE row, pixel1, pixel2, pixel3, pixel4;

    long x, y;

    double red, green, blue;

    if(!bitmap) return false;

    width = bitmap -> infoheader -> biWidth;

    height = bitmap -> infoheader -> biHeight;

    rowsize = width * 4;

    row = (LPBYTE) (bitmap -> firstRow);

    for ( y = 0; y < (int) height; y++) {

        pixel1 = row;

        pixel2 = row;

        pixel3 = row;

        pixel4 = row;

        if((y >= 0) && ((y + 1) < (int) height)) {

            pixel2 -= rowsize;

            pixel3 -= rowsize;

        }

        for ( x = 0; x < (int) width; x++) {

            if(((y + 1) < (int) height) && ((x + 1) < (int) width)) {

                pixel2 += 4;

                pixel4 += 4;

                red = sqrt(pow(((double) pixel1[2] - pixel2[2]), 2) + pow(((double) pixel3[2] - pixel4[2]), 2));

                green = sqrt(pow(((double) pixel1[1] - pixel2[1]), 2) + pow(((double) pixel3[1] - pixel4[1]), 2));

                blue = sqrt(pow(((double) pixel1[0] - pixel2[0]), 2) + pow(((double) pixel3[0] - pixel4[0]), 2));

            }

            else if(((y + 1) >= (int) height) && ((x + 1) < (int) width)) {

                pixel2 += 4;

                pixel4 += 4;

                red = sqrt(pow((double) pixel1[2], 2) + pow((double) pixel4[2], 2));

                green = sqrt(pow((double) pixel1[1], 2) + pow((double) pixel4[1], 2));

                blue = sqrt(pow((double) pixel1[0], 2) + pow((double) pixel4[0], 2));

            }

            else if(((y + 1) < (int) height) && ((x + 1) >= (int) width)) {

                red = sqrt(pow((double) pixel1[2], 2) + pow((double) pixel3[2], 2));

                green = sqrt(pow((double) pixel1[1], 2) + pow((double) pixel3[1], 2));

                blue = sqrt(pow((double) pixel1[0], 2) + pow((double) pixel3[0], 2));

            }

            else {

                red = pixel1[2];

                green = pixel1[1];

                blue = pixel1[0];

            }

            if((red + green + blue) > (double) 60) {

                if((red >= green) && (red >= blue)) {

                    red += 20;

                }

                else if((green >= red) && (green >= blue)) {

                    green += 20;

                }

                else {

                    blue += 20;

                }

                if(red > 255) red = 255;

                if(green > 255) green = 255;

                if(blue > 255) blue = 255;

                pixel1[2] = (BYTE) red;

                pixel1[1] = (BYTE) green;

                pixel1[0] = (BYTE) blue;

            }

            else {

                pixel1[2] = 0;

                pixel1[1] = 0;

                pixel1[0] = 0;

            }

            pixel1 += 4;

            pixel3 += 4;

        }

        row -= rowsize;

    }

    return true;

}

//Monochrome

extern "C" _declspec (dllexport) BOOL Monochrome(long object){

    RGSSBMINFO *bitmap = ((RGSSBITMAP*) (object<<1)) -> bm -> bminfo;

    DWORD rowsize;

    DWORD width, height;

    LPBYTE row;

    long x, y;

    int red, green, blue, shade;

    if(!bitmap) return false;

    width = bitmap -> infoheader -> biWidth;

    height = bitmap -> infoheader -> biHeight;

    rowsize = width * 4;

    row = (LPBYTE)(bitmap -> firstRow);

    for ( y = 0; y < (int) height; y++) {

        LPBYTE thisrow = row;

        for ( x = 0; x < (int) width; x++) {

            red = (thisrow[1] - thisrow[0] + thisrow[1] + thisrow[2]);

            red = (red * thisrow[2] / 256);

            if(red > 255) red = 255;

            green = (thisrow[0] - thisrow[1] + thisrow[0] + thisrow[2]);

            green = (green * thisrow[1] / 256);

            if(green > 255) green = 255;

            blue = (thisrow[0] - thisrow[1] + thisrow[0] + thisrow[2]);

            blue = (blue * thisrow[0] / 256);

            if(blue > 255) blue = 255;

            shade = ((red + green + blue) / 3);

            thisrow[2] = shade;

            thisrow[1] = shade;

            thisrow[0] = shade;

            thisrow += 4;

        }

        row -= rowsize;

    }

    return true;

}

//Emboss

extern "C" _declspec (dllexport) BOOL Emboss(long object){

    RGSSBMINFO *bitmap = ((RGSSBITMAP*) (object<<1)) -> bm -> bminfo;

    DWORD rowsize;

    DWORD width, height;

    LPBYTE row;

    long x, y;

    int red, green, blue;

    if(!bitmap) return false;

    width = bitmap -> infoheader -> biWidth;

    height = bitmap -> infoheader -> biHeight;

    rowsize = width * 4;

    row = (LPBYTE)(bitmap -> firstRow);

    for ( y = 0; y < (int) height; y++) {

        LPBYTE thisrow = row;

        LPBYTE nextrow = row;

        if((y > 0) && ((y + 1) < (int) height)) {

            nextrow -= (width * 4);

        }

        for ( x = 0; x < (int) width; x++) {

            if(((y + 1) < (int) height) && ((x + 1) < (int) width)) {

                nextrow += 4;

                red = (thisrow[2] - nextrow[2] + 128);

                green = (thisrow[1] - nextrow[1] + 128);

                blue = (thisrow[0] - nextrow[0] + 128);

            }

            else {

                red = (thisrow[2] + 128);

                green = (thisrow[1] + 128);

                blue = (thisrow[0] + 128);

            }

            red = abs(red);

            green = abs(green);

            blue = abs(blue);

            if(red > 255) red = 255;

            if(green > 255) green = 255;

            if(blue > 255) blue = 255;

            thisrow[2] = red;

            thisrow[1] = green;

            thisrow[0] = blue;

            thisrow += 4;

        }

        row -= rowsize;

    }

    return true;

}

//contrast

/* //This will be replaced by a contrast method

extern "C" _declspec (dllexport) BOOL MinusTwo(long object){

    RGSSBMINFO *bitmap = ((RGSSBITMAP*) (object<<1)) -> bm -> bminfo;

    DWORD rowsize;

    DWORD width, height;

    LPBYTE row;

    long x, y;

    double color1, color2;

    if(!bitmap) return false;

    width = bitmap -> infoheader -> biWidth;

    height = bitmap -> infoheader -> biHeight;

    rowsize = width * 4;

    row = (LPBYTE)(bitmap -> firstRow);

    for ( y = 0; y < (int) height; y++) {

        LPBYTE thisrow = row;

        LPBYTE nextrow = row;

        if((y > 0) && ((y + 1) < (int) height)) {

            nextrow -= (width * 4);

        }

        for ( x = 0; x < (int) width; x++) {

            if(((y + 1) < (int) height) && ((x + 1) < (int) width)) {

                nextrow += 4;

                color2 = (((nextrow[2] * 0.3) + (nextrow[1] * 0.6) + (nextrow[0] * 0.1)) / 10);

            }

            else {

                color2 = 0;

            }

            color1 = (((thisrow[2] * 0.3) + (thisrow[1] * 0.6) + (thisrow[0] * 0.1)) / 10);

            if((color1 - color2) > 0.2) {

                thisrow[2] = 0;

                thisrow[1] = 0;

                thisrow[0] = 0;

            }

            else {

                thisrow[2] = 255;

                thisrow[1] = 255;

                thisrow[0] = 255;

            }

            thisrow += 4;

        }

        row -= rowsize;

    }

    return true;

}

*/

 

//Sepia

extern "C" _declspec (dllexport) BOOL Sepia(long object){

    RGSSBMINFO *bitmap = ((RGSSBITMAP*) (object<<1)) -> bm -> bminfo;

    DWORD rowsize;

    DWORD width, height;

    LPBYTE row;

    long x, y;

    double red, green, blue, avg;

    if(!bitmap) return false;

    width = bitmap -> infoheader -> biWidth;

    height = bitmap -> infoheader -> biHeight;

    rowsize = width * 4;

    row = (LPBYTE)(bitmap -> firstRow);

    for ( y = 0; y < (int) height; y++) {

        LPBYTE thisrow = row;

        for ( x = 0; x < (int) width; x++) {

            avg = (thisrow[2] + thisrow[1] + thisrow[0]) / 3;

            red = (((thisrow[2] * 0.740) + (thisrow[1] * 0.475) + (thisrow[0] * 0.225)) + avg) / 2;

            green = (((thisrow[2] * 0.565) + (thisrow[1] * 0.335) + (thisrow[0] * 0.180)) + avg) / 2;

            blue = (((thisrow[2] * 0.325) + (thisrow[1] * 0.278) + (thisrow[0] * 0.110)) + avg) / 2;

            if(red > 255) red = 255;

            if(green > 255) green = 255;

            if(blue > 255) blue = 255;

            thisrow[2] = (BYTE) red;

            thisrow[1] = (BYTE) green;

            thisrow[0] = (BYTE) blue;

            thisrow += 4;

        }

        row -= rowsize;

    }

    return true;

}

//Sharpen

extern "C" _declspec (dllexport) BOOL Sharpen(long object){

    RGSSBMINFO *bitmap = ((RGSSBITMAP*) (object<<1)) -> bm -> bminfo;

    DWORD rowsize;

    DWORD width, height;

    LPBYTE row;

    long x, y;

    double red, green, blue, ap;

    if(!bitmap) return false;

    width = bitmap -> infoheader -> biWidth;

    height = bitmap -> infoheader -> biHeight;

    rowsize = width * 4;

    row = (LPBYTE)(bitmap -> firstRow);

    red = 0;

    green = 0;

    blue = 0;

    ap = 0.8;

    for ( y = 0; y < (int) height; y++) {

        LPBYTE thisrow = row;

        LPBYTE nextrow = row;

        if((y > 0) && ((y + 1) < (int) height)) {

            nextrow -= (width * 4);

        }

        for ( x = 0; x < (int) width; x++) {

            if(((y + 1) < (int) height) && ((x + 1) < (int) width)) {

                nextrow += 4;

                red += nextrow[2];

                green += nextrow[1];

                blue += nextrow[0];

            }

            red = (((thisrow[2] - (red / 3)) * ap) + thisrow[2]);

            green = (((thisrow[1] - (green / 3)) * ap) + thisrow[1]);

            blue = (((thisrow[0] - (blue / 3)) * ap) + thisrow[0]);

            if(red > 255) red = 255;

            if(green > 255) green = 255;

            if(blue > 255) blue = 255;

            if(red < 0) red = 0;

            if(green < 0) green = 0;

            if(blue < 0) blue = 0;

            thisrow[2] = (BYTE) red;

            thisrow[1] = (BYTE) green;

            thisrow[0] = (BYTE) blue;

            thisrow += 4;

        }

        row -= rowsize;

    }

    return true;

}

//Soften

extern "C" _declspec (dllexport) BOOL Soften(long object){

    RGSSBMINFO *bitmap = ((RGSSBITMAP*) (object<<1)) -> bm -> bminfo;

    DWORD rowsize;

    DWORD width, height;

    LPBYTE row;

    long x, y, xoffset, yoffset;

    int red, green, blue;

    if(!bitmap) return false;

    width = bitmap -> infoheader -> biWidth;

    height = bitmap -> infoheader -> biHeight;

    rowsize = width * 4;

    row = (LPBYTE) (bitmap -> firstRow);

    for ( y = 0; y < (int) height; y++) {

        LPBYTE thisrow = row;

        for ( x = 0; x < (int) width; x++) {

            red = 0;

            green = 0;

            blue = 0;

            for ( xoffset = -1; xoffset <= 1; xoffset++) {

                for ( yoffset = -1; yoffset <= 1; yoffset++) {

                    if ((y > 0) && ((y + yoffset) < (int) height) && ((y + yoffset) > 0) && ((x + xoffset) > 0) && ((x + xoffset) < (int) width)) {

                        LPBYTE newrow = thisrow;

                        newrow -= (yoffset * (width * 4));

                        newrow += (xoffset * 4);

                        red += newrow[2];

                        green += newrow[1];

                        blue += newrow[0];

                    }

                }

            }

            red /= 9;

            green /= 9;

            blue /= 9;

            thisrow[2] = red;

            thisrow[1] = green;

            thisrow[0] = blue;

            thisrow += 4;

        }

        row -= rowsize;

    }

    return true;

}

//Frost

extern "C" _declspec (dllexport) BOOL Frost(long object, int passes){

    RGSSBMINFO *bitmap = ((RGSSBITMAP*) (object<<1)) -> bm -> bminfo;

    DWORD rowsize;

    DWORD width, height;

    LPBYTE row;

    long x, y, z;

    int randomx, randomy;

    if(!bitmap) return false;

    width = bitmap -> infoheader -> biWidth;

    height = bitmap -> infoheader -> biHeight;

    rowsize = width * 4;

    row = (LPBYTE) (bitmap -> firstRow);

    for ( y = 0; y < (int) height; y++) {

        LPBYTE thisrow = row;

        for ( x = 0; x < (int) width; x++) {

            randomx = 0;

            randomy = 0;

            //Summate the random, so as to avoid repeating the whole process for each pass.

            //LPBYTE newrow = thisrow;

            for ( z = 0; z <= passes - 2; z++) {

                randomx += ((rand() % - 5) + 2);

            }

            for ( z = 0; z <= passes - 2; z++) {

                randomy += ((rand() % - 5) + 2);

            }

            if(((y + randomy) < (int) height) && ((x + randomx) < (int) width) && ((y + randomy) > 0 && ((x + randomx) > 0))) {

                LPBYTE newrow = thisrow;

                newrow -= (randomy * (width * 4));

                newrow += (passes * (width * 4));

                newrow += (randomx * 4 );

                newrow -= (passes * 4);

                thisrow[2] = newrow[2];

                thisrow[1] = newrow[1];

                thisrow[0] = newrow[0];

                thisrow[3] = newrow[3];

            }

            else {

                thisrow[2] = 0;

                thisrow[1] = 0;

                thisrow[0] = 0;

                thisrow[3] = 0;

            }

            thisrow += 4;

        }

        row -= rowsize;

    }

    return true;

}

 

 

//Pixelate

extern "C" _declspec (dllexport) BOOL Pixelate(long object, int size)

{

    RGSSBMINFO *bitmap = ((RGSSBITMAP*) (object<<1)) -> bm -> bminfo;

    DWORD rowsize;

    DWORD width, height;

    LPBYTE row;

    long x, y, zx, zy, wx, wy; 

    int red, green, blue, alpha;

    if(!bitmap) return false;

    if(size <= 1) return false;

    red = 0;

    green = 0;

    blue = 0;

    alpha = 0;

    width = bitmap -> infoheader -> biWidth;

    height = bitmap -> infoheader -> biHeight;

    rowsize = (width * 4 * size);

    row = (LPBYTE) (bitmap -> firstRow);

    for ( y = 0; y < (int) ((height - 1) / size); y++) 

    {

        LPBYTE thisrow = row;

        for ( x = 0; x < (int) ((width - 1) / size); x++) 

        {

            red, green, blue, alpha = 0;

            for ( zy = 0; zy == size - 1; zy++)

            {

                LPBYTE scanrow = thisrow;

                for ( zx = 0; zx == size - 1; zx++)

                {

                    red += (scanrow[2]);

                    green += (scanrow[1]);

                    blue += (scanrow[0]);

                    alpha += (scanrow[3]);

                    scanrow += 4;

                }

                scanrow -= (4 * width);

            }

            

            double block = static_cast<double>(size);

            double r = red / pow(block,2);

            r *=  sqrt(block);

            double g = green / pow(block,2);

            g *=  sqrt(block);

            double b = blue / pow(block,2);

            b *=  sqrt(block);

            double a = alpha / pow(block,2);

            a *=  sqrt(block);

            LPBYTE saverow = thisrow;

            for (wy = 0; wy == (size - 1); wy++);

            {   

                for (wx = 0; wx == (size - 1); wx++);

                {

                    thisrow[2] = (BYTE) r;

                    thisrow[1] = (BYTE) g;

                    thisrow[0] = (BYTE) b;

                    thisrow[3] = (BYTE) a; 

                    thisrow += 4;

                }

                thisrow -= (width * 4);

            }

            thisrow = saverow;

            thisrow += (4 * size) ;

        }

        thisrow -= (rowsize);

    }

    return true;

}

 

 

 /*

extern "C" _declspec (dllexport) BOOL Swap(long object1, long object2, int index){

    RGSSBMINFO *bitmap = ((RGSSBITMAP*) (object1<<1)) -> bm -> bminfo;

    RGSSBMINFO *palette = ((RGSSBITMAP*) (object2<<1)) -> bm -> bminfo;

    DWORD rowsize, pRowSize;

    DWORD width, height, pWidth;

    LPBYTE row, originalColor, newColor;

    long x, y;

    int red, green, blue, oldRed, oldGreen, oldBlue;

    if(!bitmap) return false;

    width = bitmap -> infoheader -> biWidth;

    height = bitmap -> infoheader -> biHeight;

    pWidth = palette -> infoheader -> biWidth;

    rowsize = width * 4;

    pRowSize = pWidth * 4;

    row = (LPBYTE) (bitmap -> firstRow);

    for ( y = 0; y < (int) height; y++) {

        LPBYTE thisrow = row;

        for ( x = 0; x < (int) width; x++) {

            red = thisrow[2];

            green = thisrow[1];

            blue = thisrow[0];

            originalColor = (LPBYTE) (palette -> firstRow);

            for ( int i = 0; i < (int) pWidth; i++) {

                oldRed = originalColor[2];

                oldGreen = originalColor[1];

                oldBlue = originalColor[0];

                if ( (red == oldRed) && (green == oldGreen) && (blue == oldBlue)) {

                    newColor = originalColor - (pRowSize * (index + 1));

                    thisrow[2] = newColor[2];

                    thisrow[1] = newColor[1];

                    thisrow[0] = newColor[0];

                }

                originalColor += 4;

                newColor += 4;

            }

            thisrow += 4;

        }

        row -= rowsize;

    }

    return true;

}

 

 

extern "C" _declspec (dllexport) BOOL Blank(long object){

    RGSSBMINFO *bitmap = ((RGSSBITMAP*) (object<<1)) -> bm -> bminfo;

    DWORD rowsize;

    DWORD width, height;

    LPBYTE row;

    long x, y;

    int red, green, blue;

    if(!bitmap) return false;

    width = bitmap -> infoheader -> biWidth;

    height = bitmap -> infoheader -> biHeight;

    rowsize = width * 4;

    row = (LPBYTE) (bitmap -> firstRow);

    for ( y = 0; y < (int) height; y++) {

        LPBYTE thisrow = row;

        for ( x = 0; x < (int) width; x++) {

            red = thisrow[2];

            green = thisrow[1];

            blue = thisrow[0];

            thisrow += 4;

        }

        row -= rowsize;

    }

    return true;

}

 

extern "C" _declspec (dllexport) BOOL Pixelate(long object, int size)

{

    RGSSBMINFO *bitmap = ((RGSSBITMAP*) (object<<1)) -> bm -> bminfo;

    DWORD rowsize;

    DWORD width, height;

    LPBYTE row;

    long x, y, zx, zy, wx, wy; 

    int red, green, blue, alpha;

    if(!bitmap) return false;

    if(size <= 1) return false;

    red = 0;

    green = 0;

    blue = 0;

    alpha = 0;

    width = bitmap -> infoheader -> biWidth;

    height = bitmap -> infoheader -> biHeight;

    rowsize = (width * 4 * size);

    row = (LPBYTE) (bitmap -> firstRow);

    for ( y = 0; y < (int) ((height - 1) / size); y++) 

    {

        LPBYTE thisrow = row;

        for ( x = 0; x < (int) ((width - 1) / size); x++) 

        {

            red, green, blue, alpha = 0;

            for ( zy = 0; zy == size - 1; zy++)

            {

                LPBYTE scanrow = thisrow;

                for ( zx = 0; zx == size - 1; zx++)

                {

                    red += (scanrow[2]);

                    green += (scanrow[1]);

                    blue += (scanrow[0]);

                    alpha += (scanrow[3]);

                    scanrow += 4;

                }

                scanrow += (4 * width);

            }

            double block = size;

            double r = red / pow(block,2);

            r *=  sqrt(block);

            double g = green / pow(block,2);

            g *=  sqrt(block);

            double b = blue / pow(block,2);

            b *=  sqrt(block);

            double a = alpha / pow(block,2);

            a *=  sqrt(block);

            LPBYTE saverow = thisrow;

            for (wy = 0; wy == (size - 1); wy++);

            {   

                for (wx = 0; wx == (size - 1); wx++);

                {

                    thisrow[2] = (BYTE) r;

                    thisrow[1] = (BYTE) g;

                    thisrow[0] = (BYTE) b;

                    thisrow[3] = (BYTE) a; 

                    thisrow += 4;

                }

                thisrow -= (width * 4);

            }

            thisrow = saverow;

            thisrow += (4 * size) ;

        }

        thisrow -= (rowsize);

    }

    return true;

}

*/

 

//Pixelate #2

/*

extern "C" _declspec (dllexport) BOOL Pixelate(long object, int size)

{

    RGSSBMINFO *bitmap = ((RGSSBITMAP*) (object<<1)) -> bm -> bminfo;

    DWORD rowsize;

    DWORD width, height;

    LPBYTE row, scana, scanb, scanc, reset;

    long x, y, w, h, z, wx, wy; 

    int red, green, blue, alpha;

    if(!bitmap) return false;

    if(size <= 1) return false;

    red = 0;

    green = 0;

    blue = 0;

    alpha = 0;

    width = bitmap -> infoheader -> biWidth;

    height = bitmap -> infoheader -> biHeight;

    rowsize = (width * 4);

    row = (LPBYTE) (bitmap -> firstRow);

    reset = row;

    scana = row;

    scanb = row;

    scanc = row;

    double block = size;

    for ( y = 0; y < (int) ((height - 1) / size); y++) 

    {

        LPBYTE thisrow = row;

        h = y;

        h *= size;

        for ( x = 0; x < (int) ((width - 1) / size); x++) 

        {

            w = x;

            w *= size;

            red, green, blue, alpha = 0;

            for ( z = 0; z == size - 1; z++)

            {

                scana = reset;

                scana += (4 * w);

                scana -= (rowsize * h);

                scanb = reset;

                scanb += (4 * (w + z));

                scanb -= (rowsize * h);

                scanc = reset;

                scanc += (4 * w);

                scanc -= (rowsize * (h + z));

                red += ( scana[2] + scanb[2] + scanc[2] );

                green += ( scana[1] + scanb[1] + scanc[1] );

                blue += ( scana[0] + scanb[0] + scanc[0] );

                alpha += ( scana[3] + scanb[3] + scanc[3] );

            }

            red /= pow(block,2);

            green /= pow(block,2);

            blue /= pow(block,2);

            alpha /= pow(block,2);

            red *= sqrt(block);

            green *= sqrt(block);

            blue *= sqrt(block);

            alpha *= sqrt(block);

            for (wy = 0; wy == (size - 1); wy++);

            {   

                for (wx = 0; wx == (size - 1); wx++);

                {

                    thisrow[2] = (BYTE) red;

                    thisrow[1] = (BYTE) green;

                    thisrow[0] = (BYTE) blue;

                    thisrow[3] = (BYTE) alpha; 

                    thisrow += 4;

                }

                thisrow -= (width * 4);

            }

            thisrow += (4);

        }

        thisrow -= (rowsize);

    }

    return true;

}

*/

 

/*

extern "C" _declspec (dllexport) void getpixel(int x, int y)

{

    RGSSBMINFO *bitmap = ((RGSSBITMAP*) (object<<1)) -> bm -> bminfo;

    DWORD rowsize;

    DWORD width, height;

    LPBYTE row;

    long x, y;

    int red, green, blue;

    if(!bitmap) return false;

    width = bitmap -> infoheader -> biWidth;

    height = bitmap -> infoheader -> biHeight;

    if(x>=width) return false;

    if(y>=height) return false;

*/
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top