Not logged inGosu Forums
Forum back to libgosu.org Help Search Register Login
Up Topic Gosu / Gosu Exchange / Image scaling problem? (FULLSCREEN)
- - By Gammel Date 2016-02-19 18:24
Maybe i'm doing something wrong, but after drawing a 8x8 image all over the screen (tile layer) scaled by 4x (32x32), a black line appears at the top of the screen.

This only happens in fullscreen with a 8x8 scaled image with :retro=>true.
Also, if :retro is false all the screen looks like a grid (nice way to make a map editor :P)

Here's the code: (I'm using a 8x8 blue square as the image to tile).

require 'gosu'

class Window < Gosu::Window
 
 
  def draw()
    (Gosu::available_width/32).to_i.times do |x|
      (Gosu::available_height/32).to_i.times do |y|
        @img.draw( x*32, y*32, 1, 4, 4)
      end
    end
  end
 
  def update()
   
  end
 
  def initialize()
    super Gosu::available_width, Gosu::available_height, true
   
    @img = Gosu::Image.new("img.png", {:retro=>true})
  end
 
end

win = Window.new()
win.show
Parent - - By jlnr (dev) Date 2016-02-20 00:27
Gosu::available_height returns the height available for running games in *windowed* mode, so if you are on Windows, this will be the same as Gosu::screen_height minus space for the start menu/task bar at the bottom.
You should be seeing a black bar at the top and bottom each, and you are probably looking for Gosu::screen_width and Gosu::screen_height instead.

And if you want to stretch images without :retro => true and without producing a grid effect, :tileable => true was designed exactly for that purpose :) Hope that helps!
Parent - - By Gammel Date 2016-02-20 02:04
:tileable seems to have solved the problem with resizing, however, after changing available_height with screen_height the bottom black bar dissapeared, but the top black bar is still there. Is that supposed to happen?

require 'gosu'

class Window < Gosu::Window
 
 
  def draw()

    ((Gosu::screen_width/32)+1).times do |x|
      ((Gosu::screen_height/32)+1).times do |y|
        @img.draw( (x*32), (y*32),0,4,4)
      end
    end
   
    Gosu::draw_rect(0,0,Gosu::screen_width, 32, Gosu::Color::WHITE)
  end
 
  def update()
   
  end
 
  def initialize()
    super Gosu::screen_width, Gosu::screen_height, true
   
    @img = Gosu::Image.new("img.png", {:retro=>true, :tileable=>true})
  end
 
end

win = Window.new()
win.show
Parent - By nietzschette Date 2016-02-20 09:24
try replacing line 10 in your draw function with this

        @img.draw( (x*32), (y*32),1,4,4)

let us know if that fixes it.
Parent - By jlnr (dev) Date 2016-02-20 10:36
Nope. Can you please post a screenshot? Which operating system and which version of Gosu are you using?
Parent - - By Gammel Date 2016-02-20 17:04
Not only do i get a black bar at the top, but also the white rect that takes screen_width doesn't reach it's full size (ends like 20 pixels before the screen width)

..
I can't seem to find a way to take a screenshot (as this only happens in fullscreen), but it looks like this:



(Modifying the z value didn't change anything)

(Windows 7 - 32 bits, Gosu 0.10.5)
Parent - - By jlnr (dev) Date 2016-02-20 23:51
That's really curious. I wonder if it has anything to do with your DPI settings? Are you running Windows 7 at 100%, 125% or 150% font scale? (It's somewhere in the display settings.)

I'll give it a try on my Windows 7 VM ASAP.
Parent - By Gammel Date 2016-02-20 23:56
100%.
- - By Gammel Date 2016-02-22 16:22
Tested it on another machine and i got the same results.

Any idea? I'm the only one with this problem?
Parent - - By jlnr (dev) Date 2016-02-22 16:45
Sorry for the delay, I've tested it on Windows and you are right. I can also confirm that it has already been broken in Gosu 0.10.4. Everything works as expected on OS X.

I've filed a ticket here:

https://github.com/gosu/gosu/issues/318

I hope this high priority bug gives me an excuse to spend a couple of evenings on Gosu. In the meantime, I'm sorry for this blatant error!
Parent - By Gammel Date 2016-02-22 17:02
OK, no problem!. Thanks for helping!
- - By jlnr (dev) Date 2016-02-26 15:33
0.10.6 is out and hopefully addresses this bug.
Parent - By Gammel Date 2016-02-26 16:09
Seems to work fine! Thanks!
Up Topic Gosu / Gosu Exchange / Image scaling problem? (FULLSCREEN)

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill