Yes. That's what I like to do. Could you give an example of retreiving
canvas raw data by GWT instead of JSNI?

Kevin

On Wed, Mar 4, 2009 at 4:18 AM, Matt Bishop <m...@re-entry.ca> wrote:

>
> This is pretty cool. You should try converting the data in GWT instead
> of JSNI. It could go straight to bytes, or at least it could take
> advantage of GWT's StringBuilder speed.
>
>
> On Mar 1, 4:57 pm, Kevin Tarn <kevn.t...@gmail.com> wrote:
> > Forgot to tell: getImageData method convert raw data to a Windows DIB
> > format.
> >
> > Kevin
> >
> > On Mon, Mar 2, 2009 at 8:52 AM, Kevin Tarn <kevn.t...@gmail.com> wrote:
> > > I got idea from canvas2image.js(
> http://www.nihilogic.dk/labs/canvas2image/).
> > > So I wrote a JSNI methods as below:
> >
> > >     public native String getImageData(int left, int top, int width, int
> > > height) /*-{
> >
> > >         var oData = th...@com.messenger.client.framework.canvas
> ::context.getImageData(left,
> > > top, width, height);
> >
> > >         var aImgData = oData.data;
> >
> > >     var strPixelData = "";
> > >     var y = height;
> > >         var iPadding = (4 - ((width * 3) % 4)) % 4;
> >
> > >     do {
> > >             var iOffsetY = width*(y-1)*4;
> > >             var strPixelRow = "";
> > >             for (var x=0;x<width;x++) {
> > >                     var iOffsetX = 4*x;
> >
> > >                     if (aImgData[iOffsetY+iOffsetX+2] == 0 &&
> > >                         aImgData[iOffsetY+iOffsetX+1] == 0 &&
> > >                         aImgData[iOffsetY+iOffsetX] == 0) {
> >
> > >                         strPixelRow += String.fromCharCode(255);
> > >                         strPixelRow += String.fromCharCode(255);
> > >                         strPixelRow += String.fromCharCode(255);
> > >                     } else {
> > >                         strPixelRow +=
> > > String.fromCharCode(aImgData[iOffsetY+iOffsetX+2]);
> > >                         strPixelRow +=
> > > String.fromCharCode(aImgData[iOffsetY+iOffsetX+1]);
> > >                         strPixelRow +=
> > > String.fromCharCode(aImgData[iOffsetY+iOffsetX]);
> > >                     }
> > >             }
> > >             for (var c=0;c<iPadding;c++) {
> > >                     strPixelRow += String.fromCharCode(0);
> > >             }
> > >             strPixelData += strPixelRow;
> > >         } while (--y);
> >
> > >         return strPixelData;
> > >     }-*/;
> >
> > > As above method, I got a raw data in String object. So I need another
> > > method to convert it to byte array. Here it is:
> >
> > >     public byte[] getBitmap() {
> > >         String str = getImageData(0, 0, width, height);
> > >         byte[] ar = new byte[str.length()];
> > >         for (int i=0; i<ar.length; i++)
> > >             ar[i] = (byte)((int)str.charAt(i) & 0xff);
> > >         return ar;
> > >     }
> >
> > > Hope this is helpful.
> >
> > > Kevin
> >
> > > On Sat, Feb 28, 2009 at 10:41 PM, Fabrício Cabral <
> fabrici...@gmail.com>wrote:
> >
> > >> Could you say how you solved this problem? For historic purpose...
> >
> > >> Thanks in advance!
> >
> > >> > I have solved problem.
> >
> > >> > Kevin
> > >> --
> > >> --fx
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to Google-Web-Toolkit@googlegroups.com
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to