Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Highlighted
Developer
Developer
Posts: 1,123
Registered: ‎02-10-2009
My Device: 8130 / 8350 / 9530 / 9550 / 9850 / PlayBook
My Carrier: Verizon
Accepted Solution

Writing out SVG Images, DOM Documents

Is there any inherent way to write out an SVG image or DOM document to a file? If I could get it into a byte array I could figure it from there, but I see no way to write out the document or image once it's created.
Developer
Posts: 1,415
Registered: ‎07-30-2008
My Device: Not Specified

Re: Writing out SVG Images, DOM Documents

I haven't used the BB classes in question but I'm not sure I understand your question. Presumably you could

parse an SVG source file with an XML parser and make a DOM. Alternatively, you could readout the pixels

from a rendered SVG if you have a renderer that writes to something like a Graphics context. You can't

take a random bitmap and recreate the source SVG as the model information is lost.

 

Developer
Developer
Posts: 1,123
Registered: ‎02-10-2009
My Device: 8130 / 8350 / 9530 / 9550 / 9850 / PlayBook
My Carrier: Verizon

Re: Writing out SVG Images, DOM Documents

I hava an app that I designed that allows the user to jot down a message by writing on the screen instead of typing. I want to be able to save the message until the user deletes it. I want to put the SVG in the persistent store, but there is no way to determine the size so I want to be able to write it to a stream and compress it with gzip or zlib. I want to know is there a way to write out a DOM object to a byte stream or would I have to come up with one on my own?
Developer
Posts: 1,415
Registered: ‎07-30-2008
My Device: Not Specified

Re: Writing out SVG Images, DOM Documents

well,  if you can capture a mouse trajectory that could qualify as a vector I suppose and then

that would be a candidate for an SVG representation. Failing that, you could look at any fax or

related compression schemes for binary images. I'm not sure what you are targetting for platform

or input method but if you have something you could capture as a model ( " put a circle here")

then I guess you could think about an SVG representation. What classes were you thinking

about using? I've written some SVG stuff but haven't looked at RIM or JSR support in any detail.

 

Model based compression is always my favorite- if you can desribe the generating mechanism for

something complicated ( the way something like ACELP models vocal track to compress speech)

you stand a good chance of getting a concise representation of what you care about.

 

Developer
Developer
Posts: 1,123
Registered: ‎02-10-2009
My Device: 8130 / 8350 / 9530 / 9550 / 9850 / PlayBook
My Carrier: Verizon

Re: Writing out SVG Images, DOM Documents

It is basically just a scratch pad app. So if you need to jot something down real quick, like "Call Mike" or something it would be easier to write it to the screen than typing it out (open tasks or some other app, type message, save, etc...). I have the SVG drawing completed, and I know simple SVG images can be alot smaller than a graphic image (I tried this and ended up with around a 80K or larger image with a screenshot). From what I understand a single object in the persistent store can be a max of 64K. So I want to write out the contents of the DOM document (SVG image) to a byte stream and compress it to try and make sure it is less than 64K. I see no way to write out the DOM document to a byte stream in the API, so I was wondering if there was some undocumented way to do it.
Developer
Posts: 1,415
Registered: ‎07-30-2008
My Device: Not Specified

Re: Writing out SVG Images, DOM Documents

It looks like LSSerializer would work but I've never tried any of that stuff.

Did you render and grep documentation for methods that take Document parameters?

 

How did you get the image as an SVG or did you capture it that way?

Developer
Posts: 1,415
Registered: ‎07-30-2008
My Device: Not Specified

Re: Writing out SVG Images, DOM Documents

I'm still in limbo between machines but it looks like there may be an implementor for that

interface that would make the XML doc in 4.6+

Have you looked in org.w3c.dom.ls DOMImplementationLS?

 

How did you generate the SVG DOM from user input?

 

Developer
Developer
Posts: 1,123
Registered: ‎02-10-2009
My Device: 8130 / 8350 / 9530 / 9550 / 9850 / PlayBook
My Carrier: Verizon

Re: Writing out SVG Images, DOM Documents

It tracks the TouchEvents to determine movement and draws a line if needed, if the user just touches the screen and releases it draws a circle / dot. I think I have looked at those classes, but I may be mistaken. I kinda just did a little link diving starting at the SVG api's to see if there was a way to write it out. I've never worked with SVG before so, I didn't know where to look specifically.
Developer
Developer
Posts: 1,123
Registered: ‎02-10-2009
My Device: 8130 / 8350 / 9530 / 9550 / 9850 / PlayBook
My Carrier: Verizon

Re: Writing out SVG Images, DOM Documents

I did skip those classes the first time through. They seem to be what I need. Now just to figure out how to use them. I'll let you know what I come up with if you want. Or if you know a way, I'd be glad to hear it.
Developer
Developer
Posts: 1,123
Registered: ‎02-10-2009
My Device: 8130 / 8350 / 9530 / 9550 / 9850 / PlayBook
My Carrier: Verizon

Re: Writing out SVG Images, DOM Documents

You know that was too easy. I'm almost ashamed. I think I have it figured out, I just have to code it and ty it. If i call getImplementation on the document and then getFeature on that for the LS, it will give me the serializable object to write the byte stream. All i need to do is normalize the document first to make sure the XML is well-formed.