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
Developer
rcmaniac25
Posts: 1,805
Registered: ‎04-28-2009
My Device: Z10 (STL100-4)-10.2.1.3253, Z10 (STL100-3)-10.3.1.997 Dev OS, Z30 (STA100-5)-10.3.1.997 Dev OS, Passport (SQW100-1)-10.3.0.1418, PlayBook (16GB)-2.1.0.1917

Drawing off-pixel locations

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.?

---Spends time in #blackberrydev on freenode (IRC)----
Three simple rules:
1. Please use the search bar before making new posts.
2. "Like" posts that you find helpful.
3. If a solution has been found for your post, mark it as solved.
--I code too much. Well, too bad.
Developer
rcmaniac25
Posts: 1,805
Registered: ‎04-28-2009
My Device: Z10 (STL100-4)-10.2.1.3253, Z10 (STL100-3)-10.3.1.997 Dev OS, Z30 (STA100-5)-10.3.1.997 Dev OS, Passport (SQW100-1)-10.3.0.1418, PlayBook (16GB)-2.1.0.1917

Re: Drawing off-pixel locations

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.

---Spends time in #blackberrydev on freenode (IRC)----
Three simple rules:
1. Please use the search bar before making new posts.
2. "Like" posts that you find helpful.
3. If a solution has been found for your post, mark it as solved.
--I code too much. Well, too bad.
Developer
marchywka
Posts: 1,415
Registered: ‎07-30-2008
My Device: Not Specified

Re: Drawing off-pixel locations

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.

Developer
rcmaniac25
Posts: 1,805
Registered: ‎04-28-2009
My Device: Z10 (STL100-4)-10.2.1.3253, Z10 (STL100-3)-10.3.1.997 Dev OS, Z30 (STA100-5)-10.3.1.997 Dev OS, Passport (SQW100-1)-10.3.0.1418, PlayBook (16GB)-2.1.0.1917

Re: Drawing off-pixel locations

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.

For example:

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?

---Spends time in #blackberrydev on freenode (IRC)----
Three simple rules:
1. Please use the search bar before making new posts.
2. "Like" posts that you find helpful.
3. If a solution has been found for your post, mark it as solved.
--I code too much. Well, too bad.
Developer
marchywka
Posts: 1,415
Registered: ‎07-30-2008
My Device: Not Specified

Re: Drawing off-pixel locations

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.

 

Developer
rcmaniac25
Posts: 1,805
Registered: ‎04-28-2009
My Device: Z10 (STL100-4)-10.2.1.3253, Z10 (STL100-3)-10.3.1.997 Dev OS, Z30 (STA100-5)-10.3.1.997 Dev OS, Passport (SQW100-1)-10.3.0.1418, PlayBook (16GB)-2.1.0.1917

Re: Drawing off-pixel locations

[ Edited ]

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.

---Spends time in #blackberrydev on freenode (IRC)----
Three simple rules:
1. Please use the search bar before making new posts.
2. "Like" posts that you find helpful.
3. If a solution has been found for your post, mark it as solved.
--I code too much. Well, too bad.
Developer
marchywka
Posts: 1,415
Registered: ‎07-30-2008
My Device: Not Specified

Re: Drawing off-pixel locations

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.

 

 

Developer
rcmaniac25
Posts: 1,805
Registered: ‎04-28-2009
My Device: Z10 (STL100-4)-10.2.1.3253, Z10 (STL100-3)-10.3.1.997 Dev OS, Z30 (STA100-5)-10.3.1.997 Dev OS, Passport (SQW100-1)-10.3.0.1418, PlayBook (16GB)-2.1.0.1917

Re: Drawing off-pixel locations

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.

---Spends time in #blackberrydev on freenode (IRC)----
Three simple rules:
1. Please use the search bar before making new posts.
2. "Like" posts that you find helpful.
3. If a solution has been found for your post, mark it as solved.
--I code too much. Well, too bad.
Developer
marchywka
Posts: 1,415
Registered: ‎07-30-2008
My Device: Not Specified

Re: Drawing off-pixel locations

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.

 

IF you can generate the SVG on the server that may indeed be a good appraoch, again though you would want to couple that with transcoding although even zip may be effective here even though this could COST rather than SAVE CPU time on the phone. Transcoding would be more specialized- presumably the SVG thing on the phone parses or compiles the SVG into something as is done with java or javascript. It would be nice if you could download trancoded svg, this may be a question for rim - does BIS transcode SVG?

 

 

Developer
rcmaniac25
Posts: 1,805
Registered: ‎04-28-2009
My Device: Z10 (STL100-4)-10.2.1.3253, Z10 (STL100-3)-10.3.1.997 Dev OS, Z30 (STA100-5)-10.3.1.997 Dev OS, Passport (SQW100-1)-10.3.0.1418, PlayBook (16GB)-2.1.0.1917

Re: Drawing off-pixel locations

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?

---Spends time in #blackberrydev on freenode (IRC)----
Three simple rules:
1. Please use the search bar before making new posts.
2. "Like" posts that you find helpful.
3. If a solution has been found for your post, mark it as solved.
--I code too much. Well, too bad.