develooper Front page | perl.wxperl.users | Postings from August 2019

[rt.cpan.org #130322] Wx::Image bad bytes saving by Wx::BMPHandlerSaveFile

From:
Kevin Ryde via RT
Date:
August 17, 2019 05:04
Subject:
[rt.cpan.org #130322] Wx::Image bad bytes saving by Wx::BMPHandlerSaveFile
Message ID:
rt-4.0.18-25465-1566018242-1814.130322-15-0@rt.cpan.org
Sat Aug 17 01:04:02 2019: Request 130322 was acted upon.
Transaction: Ticket created by user42_kevin@yahoo.com.au
       Queue: Wx
     Subject: Wx::Image bad bytes saving by Wx::BMPHandler SaveFile
   Broken in: (no value)
    Severity: (no value)
       Owner: Nobody
  Requestors: user42_kevin@yahoo.com.au
      Status: new
 Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=130322 >


In recent Debian i386 WxPerl 0.9932 and Wx library 3.0.4, saving a
Wx::Image using Wx::BMPHandler seems to give bad bytes in the output.

The program below gives a good file by the Wx::Image SaveFile method,
but different and apparently bad file by the Wx::BMPHandler method.

I hope I've made a correct call for the handler SaveFile.  I believe
this or something like it worked in the past.  Dunno if it's a WxPerl
problem or a Wx problem.  Saving to PNG and JPEG seem ok.  I struck this
on CUR format (variant of BMP) which is bad too.

A hex dump shows the good one

00000  42 4D 8E 02 00 00 00 00-00 00 36 00 00 00 28 00  BM........6...(.
...

and the bad one

00000  42 4D 4D 8E 02 00 00 02-00 00 00 00 00 00 00 00  BMM.............
00010  00 00 00 00 00 00 00 36-00 00 00 00 00 00 00 00  .......6........
00020  00 28 00 00 00 00 00 00-00 00 00 14 00 00 00 00  .(..............
...

The bad looks worryingly like it's got extra 00 bytes in between the
intended ones (though I've no explanation for why 4D is duplicated).
Could it be any wide char vs byte coding ?


use strict;
use Wx;

my $image = Wx::Image->new(20,10);
$image->SaveFile('/tmp/save-by-image.bmp', Wx::wxBITMAP_TYPE_BMP());

my $handler = Wx::BMPHandler->new;
open my $fh, '>', '/tmp/save-by-handler.bmp' or die $!;
$handler->SaveFile($image, $fh);
close $fh or die $!;

system "ls -l /tmp/save-by-image.bmp /tmp/save-by-handler.bmp";



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About