05-20-2010 04:34 PM
I don't see any way (without some work) to draw at a non-pixel aligned bounds. I need this so I can draw a scaled down version of an image. If I scale everything to pixel aligned bounds the image could be in the 10,000 - 100,000 pixel range in width and larger in height.
There is no way I can do this on a BlackBerry. The only soulution I can think of is to cache all the draw commands in some helper class, then have that class export a SVG 1.1 Tiny file, then open and render that. The problem is that is (probably) much slower then what I want.
Any other ideas, fixes, etc.?
05-21-2010 11:17 AM
So is SVG the best way to go? It would definitly make it easier to zoom in since all I would need to change is the affine matrix.
05-21-2010 12:03 PM
How would you do this on non-BB? That is, I don' understand your preferred solution.
Certainly if your artwork is vector to begin with, you probably have a better time with SVG.
For artbitrary image data it would be quite a trick.
05-21-2010 12:30 PM
Java and .Net allow you to draw using a float instead of an int, I probably should have said that I needed to use a float for coordinates.
I need to draw a bunch of shapes, lines, etc. to the screen and they are not pixel aligned.
drawLine(10.32f, 34.6f, 90, 105.33f);
I had a need some time ago to write a ""Shape" (java.awt.Shape) to SVG converter. I could adapt it to output a SVG file, then use the SVG file to draw to the screen. This way if I need to zoom in, pan, or rotate I can simply edit the SVG's matrix and everything will change.
It's not arbitrary image data (it is vector) but if I could use a native function (SVG is 4.6 and higher) then it would be much better but I don't know how without manually scaling the image (which I don't want to do because it is probably slower then SVG).
Does that make it any clearer?
05-21-2010 08:11 PM
I've done some simple stuff like that with vector maps but I guess you
could just keep all your data as float and round or cast to int when you draw
to desired scale. The SVG renderer may have more features or bugs but yeah
it could be quick rendering an SVG as you expect it to be mostly native but
you would need to take time generating it.
Just looking for general comments on alternatives? I don't really have
enough real usage on BB with either to help I guess. I've generated SVG from
some c++ code and it isn't too difficult but could be quicker to
just write to graphics.
05-21-2010 08:18 PM - edited 05-21-2010 08:19 PM
Understandable but I need exactness more then I need speed, I'm just looking to get as much speed as possible because it isn't an unlimited amount of time.
I am doing this for a library I am working on: http://pdfrend4bb.codeplex.com/ and a PDF would look weird if everything was rounded to pixel bounds.
05-21-2010 09:57 PM
LOL. This is really a server side task- convert it into whatever turns out to work well on BB
given display and other considerations for your usage. There are open source renderers in
java that may be an ok starting point but not sure how good the code is. Is you are going
to author SVG for example do that on the server ( and maybe consider tokenizing for
download, not sure if there are any "compiled" or better forms for SVG than the text).
I actually am working on a browser and
for a baseline I just punt pdf files to a script to extract text and download
that since most of the time that is all I need on a phone.
I guess also you want to distinguish a model from a view. Maybe in PDF this isn't clear but the document is supposed to be more than a bunch of pixels, if you have some "thing" to preserve like a vector you can keep your model however it makes sense and render each view from that.
You don't need to be dumb about it, if you have prior calculations of known goodness that can be reused great, if not you have to do what you have to do.
I've got problems with PDF on desktops, I don't really want to aide and abett someone
trying up an entire cell phone and wireless network for font downloads when the fonts on the phone would still convey the required INFORMATION. Only partially kidding but
optimizations canbe interesting.
05-21-2010 10:16 PM
LOL myself, I like challenges and found this one suitable and a demand for it. I don't have a server to run this on, the unique thing about this library is that they use a thread to do the rendering. It loads the PDF page into the thread, renders and cache it and goes on to the next thread. I would like to keep it all cell side but it will take some work.
Font's are not a problem (except NativeFont) and already are taken care of. The reason I created this thread is the background component, the converting all the vector drawings to a actual image. SVG is looking better and better right now. I could cache them in the file store and load them as needed.
Just to wrap up, servers are nice but the idea is to keep data transfer to a minimum and keep things native. The BlackBerry JVM is pretty fast when used properly, I just need to make sure I use it properly.
05-22-2010 06:23 AM
well, algoirthmic stuff in java wont care too much about platform but
sure you could have alternative impls for various tasks. The same code could be put on sever or phone. The server component is supposed to make the data transfer more apropos
to the phone and do anything to get it closer to final or native form, RIM servers already do many types of transcoding. It isn't hard to turn PDF into something more concise and closer to final form- the point of a portable format is to make it more general but even here that fails to make it compaitiible or easily used with many existing tools, code that changes it into some other format is an important reusable addition to human knowldge given that these things are everywhere now.
05-22-2010 10:15 AM
I don't know (about the BIS conversion) but just to get back on topic (we could discuss alternatives later) but would SVG look like the only real option for drawing off pixel aligned boundaries?