[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re : [Help-smalltalk] c callouts and char**
From: |
Mathieu Suen |
Subject: |
Re : [Help-smalltalk] c callouts and char** |
Date: |
Mon, 10 Jan 2011 08:32:08 +0000 (GMT) |
----- Message d'origine ----
> De : Paolo Bonzini <address@hidden>
>
> On 01/09/2011 11:31 PM, Mathieu Suen wrote:
> > When I was playing with cairo I thought there was no other way than this
> > to
>write
> > on a surface:
> > cpngSurface := Cairo.CairoPngSurface on: 'test.png' extent: address@hidden
> > data := Cairo.Cairo imageSurfaceGetData: cpngSurface cairoSurface.
> > ..
> > data at: (i*4) + (j*stride) + 3 put: (CChar value: 255) type: CChar.
> >
> > #imageSurfaceGetData: returns an instance of CObject.
> > How to make #imageSurfaceGetData: returns a CCharArray to do something
like:
> > data at: (i*4) + (j*stride) + 3 put: 255 ?
>
> Something like this?
>
> diff --git a/packages/cairo/CairoFuncs.st b/packages/cairo/CairoFuncs.st
> index e3af859..e0316c0 100644
> --- a/packages/cairo/CairoFuncs.st
> +++ b/packages/cairo/CairoFuncs.st
> @@ -96,7 +96,7 @@ CairoContext.'>
> ]
>
> Cairo class >> imageSurfaceGetData: surface [
> - <cCall: 'cairo_image_surface_get_data' returning: #cObject args:
>#(#cObject)>
> + <cCall: 'cairo_image_surface_get_data' returning: #{CByte} args:
>#(#cObject)>
> ]
>
> Cairo class >> imageSurfaceGetHeight: filename [
> diff --git a/packages/cairo/CairoSurface.st b/packages/cairo/CairoSurface.st
> index ba82e5e..097dcfd 100644
> --- a/packages/cairo/CairoSurface.st
> +++ b/packages/cairo/CairoSurface.st
> @@ -296,6 +296,11 @@ CairoLoadableFileSurface subclass: CairoPngSurface [
> ^Cairo imageSurfaceCreateFromPng: filename
> ]
>
> + data [
> + <category: 'C interface'>
> + ^Cairo imageSurfaceGetData: self cairoSurface
> + ]
> +
> save [
> "Save the contents of the surface to the PNG file specified by
> #filename."
>
>
Yeap :) Thanks
> Paolo
>