~ubuntu-branches/ubuntu/saucy/gnash/saucy-proposed

« back to all changes in this revision

Viewing changes to libcore/swf/DefineBitsTag.cpp

  • Committer: Package Import Robot
  • Author(s): Micah Gersten
  • Date: 2012-03-04 03:19:06 UTC
  • mfrom: (1.1.18) (3.1.24 sid)
  • Revision ID: package-import@ubuntu.com-20120304031906-p6q5rnb0xhgpof7o
Tags: 0.8.10-3ubuntu1
* Merge from Debian testing (FFe: LP: #940876), remaining changes:
  - Use mozilla-flashplugin as the alternative for now
  - Change xulrunner-dev build dep to firefox-dev
* Drop the plugin API porting patch, this has been fixed upstream
  - drop debian/patches*
* Drop the following change as we want Adobe's player to take priority
  if it's installed
  - Set alternative priority to 50 so that it matches Adobe Flash's priority

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
// DefineBitsTag.cpp: bitmap tag loading for Gnash.
2
2
//
3
 
//   Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010,
4
 
//   2011 Free Software Foundation, Inc
 
3
//   Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
 
4
//   Free Software Foundation, Inc
5
5
//
6
6
// This program is free software; you can redistribute it and/or modify
7
7
// it under the terms of the GNU General Public License as published by
518
518
        }
519
519
 
520
520
        case 4:
521
 
            // 16 bits / pixel
 
521
            // 15 bits / pixel
522
522
 
523
523
            for (size_t j = 0; j < height; ++j) {
524
524
 
525
525
                boost::uint8_t* inRow = buffer.get() + j * pitch;
526
526
                boost::uint8_t* outRow = scanline(*image, j);
527
527
                for (size_t i = 0; i < width; ++i) {
528
 
                    const boost::uint16_t pixel = inRow[i * 2] |
529
 
                        (inRow[i * 2 + 1] << 8);
530
 
 
531
 
                    // How is the data packed??? Whoever wrote this was
532
 
                    // just guessing here that it's 565!
533
 
                    outRow[i * channels + 0] = (pixel >> 8) & 0xF8;    // red
534
 
                    outRow[i * channels + 1] = (pixel >> 3) & 0xFC;    // green
535
 
                    outRow[i * channels + 2] = (pixel << 3) & 0xF8;    // blue
536
 
 
537
 
                    // This was saved to the first byte before, but that
538
 
                    // can hardly be correct.
539
 
                    // Real examples of this format are rare to non-existent.
 
528
                    const boost::uint16_t pix = ( inRow[i * 2]     << 8 )
 
529
                                              | ( inRow[i * 2 + 1]      ) ;
 
530
                    const double g = 255.0/31.0; // gamma correction
 
531
 
 
532
                    // 555 packing
 
533
                    // For a testcase, see:
 
534
                    // https://savannah.gnu.org/bugs/index.php?34625
 
535
                    outRow[i * channels + 0] = ( (pix >> 10) & 0x1F ) * g; // R
 
536
                    outRow[i * channels + 1] = ( (pix >>  5) & 0x1F ) * g; // G
 
537
                    outRow[i * channels + 2] = ( (pix      ) & 0x1F ) * g; // B
 
538
 
540
539
                    if (alpha) {
541
540
                        outRow[i * channels + 3] = 255;
542
541
                    }