[Resolved] Shrinking an Icon
#1
Hey, I was just wondering how I would shrink an icon. I have this right now:

Code:
bitmap = RPG::Cache.icon(item.icon_name)    self.contents.font.color = normal_color    self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 16, 16))    self.contents.draw_text(x + 20, y, width-80, 16, item.name)


It makes the area 16x16, but the icon is still normal sized.
Reply }
#2
I use this to increase graphic sizes for a zoomed effect in my CharGen project
Code:
def resize(bitmapped,flag)
    if flag == true
      temp_bmp = bitmapped.clone
      rect = Rect.new(0, 0, temp_bmp.width, temp_bmp.height)
      rect2 = Rect.new((temp_bmp.width/$game_zoom.chargen[1].to_i)*(($game_zoom.chargen[3].to_i)-1),
                       (temp_bmp.height/$game_zoom.chargen[2].to_i)*(($game_zoom.chargen[4].to_i)-1),
                       temp_bmp.width/$game_zoom.chargen[1].to_i,
                       temp_bmp.height/$game_zoom.chargen[2].to_i)
      temp_bmp = Bitmap.new(temp_bmp.width, temp_bmp.height)
      temp_bmp.stretch_blt(rect, bitmapped, rect2)
      bitmapped = temp_bmp
    end    
    return bitmapped
  end
Okay.... it may be a mess. The thing is the temp_bmp.stretch_blt(rect, bitmapped, rect2) routine.

rect is the rectangle holding the size/shape of your original
rect2 is the rectangle of your shrunk/resized image
bitmapped is your file
and temp_bmp is your new one
Up is down, left is right and sideways is straight ahead. - Cord "Circle of Iron", 1978 (written by Bruce Lee and James Coburn... really...)

[Image: QrnbKlx.jpg]
[Image: sGz1ErF.png]    [Image: liM4ikn.png]    [Image: fdzKgZA.png]    [Image: sj0H81z.png]
[Image: QL7oRau.png]    [Image: uSqjY09.png]    [Image: GAA3qE9.png]    [Image: 2Hmnx1G.png]    [Image: BwtNdKw.png%5B]
  Above are clickable links
Reply }
#3
I'm sorry, I sort of understand but how would I use this?

resize("icon name", true)

How does it know what size to switch to?

NVM let me figure this out! :) I've been trying to teach myself.

Thank you!

Ok, so I've been here... trying to figure this out. This is the new method.

Code:
if item == nil
      return
    end
    self.contents.font.color = normal_color
    #self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 16, 16))
    bitmap = RPG::Cache.icon(item.icon_name)
    rect = Rect.new(0, 0, 16, 16)
    icon = Rect.new(0, 0, 16, 16)
    bitmap.stretch_blt(rect, bitmap,icon)
    self.contents.draw_text(x + 20, y, width-80, 16, item.name)

It just comes up blank now.
Reply }
#4
I didn't know you edited your post. Last I saw was "gonna figure this out". I woulda come earlier had I known.

Well, you commented out the line that pasted the revised icon and forgot to redo it after the resize. You also performed the resize, but didn't establish it as a new bitmap. I did a little editing as you can see here.
Code:
if item == nil
  return
end
self.contents.font.color = normal_color
bitmap    = RPG::Cache.icon(item.icon_name)
newbitmap = bitmap.clone
rect      = Rect.new(0, 0, 32, 32)
rect2     = Rect.new(0, 0, 16, 16)
newbitmap = bitmap.stretch_blt(rect, bitmap, rect2)
self.contents.blt(x, y + 4, newbitmap, rect2)
self.contents.draw_text(x + 20, y, width-80, 16, item.name)
DerVVulfman's 'regular Joe' account for testing and permissions use.
Who watches the Watchmen?
Reply }
#5
I'm going to try this out asap. For some reason, I thought that the stretch blt was standalone and did not need the regular blt call.
Reply }
#6
the stretch_blt is stand alone, but you didn't apply it to the window content

Change the
Code:
bitmap.stretch_blt(rect, bitmap,icon)
self.contents.draw_text(x + 20, y, width-80, 16, item.name)

to
Code:
self.contents.stretch_blt(rect, bitmap,icon)
self.contents.draw_text(x + 20, y, width-80, 16, item.name)
Reply }
#7
Thanks I got it working properly.
Reply }


Possibly Related Threads…
Thread Author Replies Views Last Post
  Icon Display 1.0 scripts makes events impossible to go to events, which are passable Djigit 0 3,891 01-03-2015, 09:11 PM
Last Post: Djigit
   [Resolved] DerVVulfman Animated Battlers - Physical attacks result in looping Samven 2 6,258 07-07-2012, 10:56 AM
Last Post: Samven
   Icon next to ennemy name in battle ? mageone 6 9,036 10-09-2009, 04:57 PM
Last Post: mageone
   [Resolved] Equipment Scene Problem Yin 4 7,283 08-29-2009, 11:01 PM
Last Post: Yin



Users browsing this thread: 1 Guest(s)