Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add jpg support for Qt::Pixmap on Windows #32

Closed
stomar opened this issue Apr 2, 2012 · 9 comments
Closed

Add jpg support for Qt::Pixmap on Windows #32

stomar opened this issue Apr 2, 2012 · 9 comments

Comments

@stomar
Copy link
Contributor

stomar commented Apr 2, 2012

Creating a QPixmap with a jpg file does not work on Windows and results
in a null pixmap (on Linux it works just fine).

require 'Qt'
app = Qt::Application.new ARGV
Qt::Widget.new do
  pixmap = Qt::Image.new 'test.jpg'
  puts 'Null Pixmap'  if pixmap.null?  # => Null Pixmap
  puts Qt::ImageReader.supported_image_formats  # => bmp, pbm, pgm, png, ppm, xbm, xpm
end

System:

  • Windows XP Professional
  • Ruby 1.9.3-p125
  • qtbindings 4.6.3.4 x86-mingw32
@kanfet
Copy link

kanfet commented Jul 25, 2012

Workaround:

  1. Create 'plugins' folder in your application folder
  2. Copy 'imageformats' folder to this 'plugins' folder from qtbindings gem, e.g. for me it is 'C:\RoR\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\qtbindings-4.6.3.4-x86-mingw32\bin\plugins'
  3. Add line after creating Qt::Application
app = Qt::Application.new ARGV
app.add_library_path('./plugins')

OR
You can just add line with correct path to 'plugins' folder in qtbindings gem

app = Qt::Application.new ARGV
app.add_library_path('path/to/gems/qtbindings/bin/plugins')

@kanfet
Copy link

kanfet commented Jul 25, 2012

Update to previous comment
Universal way:

app.add_library_path(Gem::Specification.find_by_name("qtbindings").gem_dir + '/bin/plugins')

@jmthomas
Copy link
Collaborator

The good news is that the current QtBindings built using the QT 4.8 works out of the box. When I run your program I get this for supported_image_formats:
bmp, gif, ico, jpeg, jpg, mng, pbm, pgm, png, ppm, svg, svgz, tga, tif, tiff, xbm, xpm

kanfet thanks for the workaround.

@stomar
Copy link
Contributor Author

stomar commented Sep 28, 2012

Since I am using the version from rubygems.org I am still using 4.6, but I am looking forward to the new version.

@ kanfet: Thanks a lot, your solution works like a charm.

@jmthomas
Copy link
Collaborator

jmthomas commented Oct 2, 2012

Ryan just pushed the new 4.8.3.0 qtbindings gem. Let me know if this fixes your problem.

@stomar
Copy link
Contributor Author

stomar commented Oct 5, 2012

On the system mentioned on top the behaviour is still the same, even with qtbindings 4.8.3.0 x86-mingw32. But for me including the plugins path works fine.

@kybu
Copy link

kybu commented Sep 24, 2014

JPG is still not supported out-of-box.

@ryanmelt
Copy link
Owner

After creating your application, you just need to add this line:

Qt::Application.instance.addLibraryPath(Qt::PLUGIN_PATH)

I will update the README.

@ghost
Copy link

ghost commented Feb 13, 2017

Still not working, even after hardcoding the plugin path... JPEG SHOULD BE OUT OF THE BOX. No... plugins.. . these are known to be a pain in the ass! (for example: "windows plugin"... ahhhh)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants