Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion PDL image to SDL::Surface

Received: by 10.180.106.102 with SMTP id gt6mr4692439wib.0.1348685103221;
        Wed, 26 Sep 2012 11:45:03 -0700 (PDT)
Newsgroups: perl.sdl.devel
Path: q11ni66782080wiw.1!nntp.google.com!feeder1.cambriumusenet.nl!feed.tweaknews.nl!194.109.133.85.MISMATCH!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!feeds.phibee-telecom.net!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!nntp.develooper.com!nntp.perl.org
Return-Path: <devel.chm...@gmail.com>
Mailing-List: contact sdl-devel-h...@perl.org; run by ezmlm
Delivered-To: mailing list sdl-de...@perl.org
Received: (qmail 8340 invoked from network); 26 Sep 2012 18:40:29 -0000
Received: from x1.develooper.com (207.171.7.70)
  by x6.develooper.com with SMTP; 26 Sep 2012 18:40:29 -0000
Received: (qmail 2446 invoked by uid 225); 26 Sep 2012 18:40:29 -0000
Delivered-To: sdl-de...@perl.org
Received: (qmail 2441 invoked by alias); 26 Sep 2012 18:40:29 -0000
X-Spam-Status: No, hits=-2.5 required=8.0
	tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS
X-Spam-Check-By: la.mx.develooper.com
Received: from mail-lb0-f169.google.com (HELO mail-lb0-f169.google.com) (209.85.217.169)
    by la.mx.develooper.com (qpsmtpd/0.28) with ESMTP; Wed, 26 Sep 2012 11:40:23 -0700
Received: by lbok6 with SMTP id k6so2696248lbo.14
        for <sdl-de...@perl.org>; Wed, 26 Sep 2012 11:40:18 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20120113;
        h=mime-version:in-reply-to:references:date:message-id:subject:from:to
         :cc:content-type;
        bh=bVsr7eBDCKPCwRG8t1hmdXhJw7bk8Opvhio+9WPl7dw=;
        b=VjV9MvJU9DkLLQ24NLwOy1Z2UGd/bxncASwUgUz34UDl83tYcS04oCv5Yb1+fYBbjh
         ZkbIjxbmBIrrA3jmj0DZPeqD6SwJTHJgjZcbglWv23uB1e4cltPPqqykntOTaVvfSIyA
         Nh4F9SPCe7YdhsWzjIp3seIcmdsikLVDc3vFYCx+kj73Mqtloi4JAZ3nLp3EXgZSfatM
         vRTWlH2Pf3iNQwmghzukqoBJAzIZyK7ah1VymaZos9Rq5HZo7oa6lejqebPzYefCl9nj
         kbSbtokTcqbGb9it7Hzvv9VEIWdYkZCLnupAXgjVrmg11av86aFVK0ahGi6mFZj3Vbu+
         Ineg==
MIME-Version: 1.0
Received: by 10.112.27.232 with SMTP id w8mr745751lbg.77.1348684818384; Wed,
 26 Sep 2012 11:40:18 -0700 (PDT)
Received: by 10.112.85.5 with HTTP; Wed, 26 Sep 2012 11:40:18 -0700 (PDT)
In-Reply-To: <CAPTtex+hO5jvHP8joRZvJs0X5PrkEHnvDMARrED7L2xDHX4...@mail.gmail.com>
References: <505F5E0E.2080...@froggs.de>
	<CAPTtex+ioBqm-0e3aJRq+M_EjcmV7N4xq-W9+6+QVnotSug...@mail.gmail.com>
	<5060712A.7020...@froggs.de>
	<CAPTtexLV_1B6SxC8wTEY1idEa+pfmtxUUfRQsZyxgHW_ojq...@mail.gmail.com>
	<CAPTtexKBGsmRJE2k1eLRdOxwMZkgRJxvTR7XZeeD+jdjMz4...@mail.gmail.com>
	<CAMiwcjZxbeXt_r56_jx7_g9oT6XHjYAJX1Ku4s1KJHZupoU...@mail.gmail.com>
	<CAPTtex+hO5jvHP8joRZvJs0X5PrkEHnvDMARrED7L2xDHX4...@mail.gmail.com>
Date: Wed, 26 Sep 2012 14:40:18 -0400
Message-ID: <CAPTtexLVCEL7kn41k4mzo3OyKaUCvFrv8g-6doedjtYRVu=...@mail.gmail.com>
Subject: Re: PDL image to SDL::Surface
To: Kartik Thakore <thakore.kar...@gmail.com>
Cc: Tobias Leich <em...@froggs.de>, sdl-devel <sdl-de...@perl.org>
X-Virus-Checked: Checked
Approved: n...@nntp.perl.org
From: devel.chm...@gmail.com (Chris Marshall)
Content-Type: text/plain; charset=ISO-8859-1

On Mon, Sep 24, 2012 at 12:46 PM, Chris Marshall <devel.chm...@gmail.com> wrote:
> Hi Kartik-
>
> I don't have a working SDL module install that I could
> check things out on.  The posted gist seemed like a
> regression of using direct PDL manipulation to read and
> copy the image data to an SDL surface.
>
> The pdl.pl example seemed ok to me until I tried looking
> at the latest XS code where it seemed that the SDL module
> doesn't not accept a packed string data as input to the
> "surface from" routines.

Still don't have an SDL install but reviewing objects/Surface.xs
a bit more it appears that the ->get_pixels_ptr() does return a
scalar perl reference to a PV with the string pointer being the
pointer to the pixel data.

However, the ->new_from() method appears to assume the
pixel pointer is actually poked into the RV slot of the dereferenced
SV rather than the PV string.  This seems inconsistent.

--Chris


> On Mon, Sep 24, 2012 at 12:39 PM, Kartik Thakore
> <thakore.kar...@gmail.com> wrote:
>> Whats wrong with
>> https://github.com/PerlGameDev/SDL_Manual/blob/master/code_listings/pdl.pl ?
>>
>>
>> On Mon, Sep 24, 2012 at 12:36 PM, Chris Marshall <devel.chm...@gmail.com>
>> wrote:
>>>
>>> Looking back through the code to the original SDL_Perl
>>> I found version 2.0.5 which allows one to actually create
>>> an SDL surface from pixel data.  More recent versions
>>> appear to copy the data and as far as I can tell, there is
>>> no way to directly create an SDL surface from external
>>> data.
>>>
>>> If that is the case (that SDL_CreateRGBSurfaceFrom is
>>> not accessible from the perl API), have you implemented
>>> another approach to achieve this?
>>>
>>> Regards,
>>> Chris
>>>
>>> On Mon, Sep 24, 2012 at 12:07 PM, Chris Marshall <devel.chm...@gmail.com>
>>> wrote:
>>> > On Mon, Sep 24, 2012 at 10:41 AM, Tobias Leich <em...@froggs.de> wrote:
>>> >> Hi Chris,
>>> >>
>>> >> The performance is poor of course.
>>> >>
>>> >> I tried to use the piddle's pointer (->dataref or so) but it looks like
>>> >> it is not pointing to a usable memory area.
>>> >
>>> > $piddle->get_dataref returns a scalar reference to a perl
>>> > PV whose string content _is_ the data block.  You should
>>> > be able to get the starting location for the pixel data (i.e.,
>>> > the string) via SvPV.
>>> >
>>> >> It looks like there are more than 4 bytes per pixel, and libSDL can't
>>> >> handle that.
>>> >
>>> > Per the above, the get_dataref returns an RV to an Sv with
>>> > the data in the string.  It is just a contiguous block of memory.
>>> > As far as I know, all the SDL memory buffers are just
>>> > contiguous blocks of memory (ignoring variations due to
>>> > stride, alignment,...)
>>> >
>>> >> The pdl.pl example is working, I see colored squares.
>>> >
>>> > I don't know what the output should look like.  I'm
>>> > cc-ing our PDL mailing list in the hopes that someone
>>> > with access to both PDL and SDL can give it a try.
>>> >
>>> > Is there a cygwin install of SDL and libSDL?
>>> >
>>> >> I think we should need to improve our examples btw, there is not a
>>> >> single comment, thats bad.
>>> >> In the pdl.pl is a var $ref, which is never used. Thats a bit
>>> >> confusing.
>>> >
>>> > I think the ref is from a previous iteration in the code
>>> > trying to get things working.
>>> >
>>> > Speaking of documentation, do you have any on the
>>> > actual perl<->libSDL bindings an data structures?  Trying
>>> > to read XS is not the simplest way to sort things out---
>>> > especially since I am far for an expert on some of the
>>> > tricky XS technologies.
>>> >
>>> > --Chris
>>> >
>>> >> Cheers, Tobias
>>> >>
>>> >> Am 24.09.2012 16:09, schrieb Chris Marshall:
>>> >>> I took a look at the gist and it looks reasonable
>>> >>> (I can't run it because I don't have the SDL module
>>> >>> and lib installed on my system), however...
>>> >>>
>>> >>> I would expect the performance to be *very* poor
>>> >>> since the image data is essentially being converted
>>> >>> from packed byte data to a perl list and then poked
>>> >>> a byte at a time into the SDL surface data.
>>> >>>
>>> >>> The better approach would be to wrap a PDL object
>>> >>> (a.k.a. piddle) into an SDL surface.  Then you could
>>> >>> just lock, copy the data via a PDL direct assignment,
>>> >>> unlock and use SDL.  There is an examples/pdl.pl
>>> >>> that shows how to do the wrapping.
>>> >>>
>>> >>> BUT, I took a look at the xs code and it appears
>>> >>> that your SDL_Surface objects no longer use a
>>> >>> packed-string representation for the SDL surface
>>> >>> data.  If that is the case, I would be surprised if
>>> >>> the pdl.pl example works at all now.
>>> >>>
>>> >>> If someone could verify this, I would appreciate it.
>>> >>> If that is the case, it should be straightforward to
>>> >>> modify the SDL_CreateRGBSurfaceFrom routine
>>> >>> to allow for a SvPV for pixel data as one alternative.
>>> >>>
>>> >>> Given the power of PDL for whole-image data
>>> >>> manipulation, allowing for easy interoperability
>>> >>> with the current SDL module would benefit both
>>> >>> our user and developer communities.
>>> >>>
>>> >>> Regards,
>>> >>> Chris
>>> >>>
>>> >>>
>>> >>> On Sun, Sep 23, 2012 at 3:07 PM, Tobias Leich <em...@froggs.de> wrote:
>>> >>>> Hi, Andrei asked some days ago how to load an image via PDL and but
>>> >>>> it
>>> >>>> in a Surface to use it in SDL.
>>> >>>>
>>> >>>> The example is here: https://gist.github.com/3772701
>>> >>>>
>>> >>>> I'll put that in the examples folder too.
>>> >>>>
>>> >>>> Cheers, Tobias
>>> >>
>>
>>