How to Draw over a Photo In CN1

67 views
Skip to first unread message

shop.servic...@gmail.com

unread,
Nov 10, 2017, 5:22:16 PM11/10/17
to CodenameOne Discussions
If you are experiencing an issue please mention the full platform your issue applies to:
IDE: NetBeans/Eclipse/IDEA 8.3
Desktop OS Windows 10
Simulator 7.3
Device IOS, Android 7

How to Take A Photo of an engine compartment for example and draw on top of the image to point out say a worn belt (See attached Photo)

Regards.
DrawOnPhotoExample.PNG

Shai Almog

unread,
Nov 11, 2017, 12:36:40 AM11/11/17
to CodenameOne Discussions
You create a mutable image using something like this:

Image img = Image.createImage(width,height, argbBackgroundColor);
Graphics g = img.getGraphics();


g
.drawImage(photo, 0, 0);
g
.drawString(...);


It's discussed in the graphics section more in depth. You can then save the data to a file using ImageIO.

shop.servic...@gmail.com

unread,
Nov 11, 2017, 2:04:00 PM11/11/17
to CodenameOne Discussions
I have been unsuccessful in understanding how to accomplish this.

Can you provide me an executable code that will load an image and allow me to draw over it?

Most appreciated!

regards.

Dave Dyer

unread,
Nov 11, 2017, 4:14:58 PM11/11/17
to CodenameOne Discussions
One caveat to add - the drawing has to be done in the EDT thread.


On Saturday, November 11, 2017 at 11:04:00 AM UTC-8, shop.servic...@gmail.com wrote:
I have been unsuccessful in understanding how to accomplish this.

Can you provide me an executable code that will load an image and allow me to draw over it?

The same code you use to display and image and then write over it in a window would be used
to draw over an image.   If your question is really "how do I implement photoshop"
that's out of scope for sure.


 

shop.servic...@gmail.com

unread,
Nov 11, 2017, 4:48:50 PM11/11/17
to codenameone...@googlegroups.com
Just looking for a simple example Form that has a background image like a picture of a worn belt on a car that I can draw an arrow with my finger to show the area I want my customer to see.

Any help would be appreciated.

Sent from my Huawei tablet
--
You received this message because you are subscribed to a topic in the Google Groups "CodenameOne Discussions" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/codenameone-discussions/4-bXpqtxDSo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to codenameone-discu...@googlegroups.com.
Visit this group at https://groups.google.com/group/codenameone-discussions.
To view this discussion on the web visit https://groups.google.com/d/msgid/codenameone-discussions/93fc6644-6264-4bfd-8cd8-847c494613a1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Dave Dyer

unread,
Nov 11, 2017, 6:45:51 PM11/11/17
to CodenameOne Discussions

It sounds like you are not a programmer, or at least are not experienced with graphics.
you need one.

shop.servic...@gmail.com

unread,
Nov 11, 2017, 7:58:06 PM11/11/17
to codenameone...@googlegroups.com
On the contrary, I am experienced in Java however weak ion graphics, however having said that, I do have difficulty working with graphics with the codenameone platform.

I do have a working example of drawing freehand using Signature Component class and was looking to see if anyone has implement Ed this on top of an image .

Respectfully, it sounds like you have no interest in helping,
Thanks any way for your time.


Sent from my Huawei tablet


-------- Original Message --------
Subject: [codenameone-discussions] Re: How to Draw over a Photo In CN1
From: Dave Dyer
To: CodenameOne Discussions
CC:


--
You received this message because you are subscribed to a topic in the Google Groups "CodenameOne Discussions" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/codenameone-discussions/4-bXpqtxDSo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to codenameone-discu...@googlegroups.com.
Visit this group at https://groups.google.com/group/codenameone-discussions.

Shai Almog

unread,
Nov 12, 2017, 12:41:40 AM11/12/17
to CodenameOne Discussions
There is a full sample in the developer guide section on graphics.

The code I provided is literally that. Try adding the image to a label and see that the new Image created can be manipulated via the Graphics object you get from it. Graphics is pretty easy to work with once you try it.

Dave Dyer

unread,
Nov 13, 2017, 12:40:31 PM11/13/17
to CodenameOne Discussions
I apologize for being pointedly un-helpful. 

I think you need a more general codename1 graphics tutorial, and could benefit by dissecting and modifying
some of the demos which use images.  What you really want is the "simplepaint" demo, which doesn't
exist.   In addition to the graphics, you're going to need custom pointer event handling to collect the touched
coordinates.

Shai Almog

unread,
Nov 14, 2017, 12:32:48 AM11/14/17
to CodenameOne Discussions
I tried building a sample like that but it's pretty hard to balance a decent looking sample with this functionality. There is a simple paint sample within the developer guide just not as a standalone sample.
Reply all
Reply to author
Forward
0 new messages