canvas for pixel drawing in GTK3 (gtk-rs) - user-interface

I just started to use gtk3, and I overwhelmed. I want to draw a pixel rendering (a function graph, drawn in realtime) in a window. I was able to create a window, following some examples, but I can't find information on pixel drawing. I need keywords to google (is it called 'canvas'? Pixel map? Drawing area?), and some advises on how to do it right. Should I keep a separate buffer and do copy every time I need to update window? Or can I just draw into existing gtk object?

For the examples you can generally check the documentation page of the crate itself. There are examples shown in crate documentation.
You can check the documentation of the crate from here.
You can draw your shapes on to the drawing area which is shown as example here on the documentation itself
As far as I have seen, it is pretty much ported with same function and struct names for GTK 3.0.
I need keywords to Google
You can basically google for the GTK library itself and the examples to get the insight about GTK and the easily implement with the help of documentation.
Getting started with GTK 3.0

Related

How can I draw images, lines, etc. on google maps

I'm investigating how I might best create an app that allows drawing of arbitrary shapes, images, etc. on google maps, based on lat/lon coords of the shapes or coords/rotations for images. Surprisingly I haven't found anything out there that offers much in the way of flexibility. Scribble-maps has created something close to what I'd aim for, but they're using flash. I'd ideally like to build something that draws on the google maps html map.
I suppose I could build a div, lay it on top of the map, and if I can listen on the map scroll/zoom events I should be able to figure out how to do everything myself. Thoughts?
You need to use overlays, check the Google API documentation.
There's an example of mouse interaction to draw lines in the Polyline Arrays section. To show images have a look at the Ground Overlays section.
I know this is a very a late response, but we have launched an API for Scribble Maps. You can check it out at http://www.scribblemaps.com/api/

Placing images on top of other images in wxpython

I know this question is pretty basic, and I'm sorry for posting it, but I literally have spent the last hour googling and I still havent found an answer.
I coded a blackjack game using pygame, and want to convert it to wxpython mostly as a way to learn wxpython. In pygame the graphics are easy, I have a base image I display (basically just the table), and then I can just display other images on top of it as the action unfolds, for example the cards. Each time the player hits I just draw a new card in a different position. When The hand is over and I want to go to the next hand, I just display the base image again, and it covers everything up and viola! Its really simple all I have to use is blit() and pygame.display.update().
I cant seem to find anyway to do this in wxpython. All the examples I find are for drawing items in new widgets, or drawing vector graphics over an image, or opening new frames with images, etc.
any help is greatly appreciated, thank you very much.
--Daniel
The AlphaDrawing example in the wxPython demo shows how to overlap multiple drawings. This uses wx.GraphicContext / wx.GCDC. If you look at the documentation, you'll note that it has CreateBitmapFromImage and CreateBitmap methods that probably apply to what you want to do. See also the DragImage demo and the following links for related information:
wx python card game
http://rummy-py.sourceforge.net/ (look at the original that was done in wx)
I found this post, which reading the comments, does a good job of showing me want I was looking for.
Delete image in wxpython?

How to crop only certain area using HTML5 + Javascript or server side language?

Before asking my question, I have a test page to make it everyone understand my question better. The URL is http://iamthemoon.com/crop/
You can move the red selection.
I like to crop only the area of red selection. I thought it could be done easily in HTML5 canvas, but that was my mistake. First I googled about it 2 days, but I couldn't find a solution. There are many HTML5 based cropping tools, but they only have square selection.
I then looked into PHP GD and imagemagick, but I couldn't find a solution as well.
I looked at the adobe online photoshop, but they're missing free-form lasso tool or free-form selection tool as well.
did anyone see a similar javascript/php/ruby/ or any other web-based technology?
or is this even possible?
just to answer to the question if this is possible.
I had to deal with same problem and took me a (full) weekend to solve it using HTML5 .
Have a look at a demo here.
Hope it helps.
EDIT:
Just a bit of pseudocode:
1.Draw the picture on canvas.
2.Record mouse clicks on canvas.
3.Draw a pattern using the mouse clicks coordinates
4.Fill pattern with original image.
5. Replace original image with pattern.
EDIT:
Source code released https://github.com/netplayer/crop
I'm working on the same subject. My idea now was to draw the opposite polygon(s) and make these transparent using imagecolorallocatealpha.
The polygon is then drawn with imagefilledpolygon. For the client side we will be using predefined images (thus predefined polygons in php). I have come across this as well: http://brittonkerin.com/image_region_selector/irs_demo.html.
Hope this helps somewhat.
http://shedlimited.debrucellc.com/
use html5 to draw the line/ coordinates,
than just use clip() instead of stroke

Geoserver and dynamic markers

I am really sorry to post this question, because most likely the solution will be really simple. But I am completely out of search string ideas.
I have a running Geoserver and some custom shapefiles describing buildings etc. I can requesting maps as pngs with the WMS interface and display on a website. So for so good.
In the next step I want to enable the user to specify a coordinate an draw a little marker on the map. This position should not be stored anywhere, I just want to draw it for this user. I am pretty sure this is possible with a WMS request and an inline feature, but I had not any luck finding a working solution and I am out of google search strings.
Please help me before I start drawing overlays over a png map.
You can do this with an inline feature in your SLD - See http://lyceum.massgis.state.ma.us/wiki/doku.php?id=wms:sld:inline_feature for an example.
You can let OpenLayers do the drawing on the client.
Check this example to see how it can be done. It demonstrates how to draw lines, points, and polygons:
http://dev.openlayers.org/releases/OpenLayers-2.10/examples/draw-feature.html

Setting up OpenGL/Cuda interop in Windows

I am writing a DLL that needs to do some work in Cuda 3.2 and some work in OpenGL. OpenGL will render some grayscale images that my Cuda code needs to read in and modify, and then give back to OpenGL as a texture. I believe I need to create PBOs to do that. I have done some basic OpenGL stuff before but never worked with extensions, and that's where my problem is - I've been searching for 2 days and so far haven't been able to find a working example, despite wading through pages and pages of code. None of the samples I've tried work (and I'm sure my vid card will support it, being a GTX470)
Some specific questions:
1. I installed the nvidia opengl sdk. Should I be using glew.h and wglew.h to access the extensions?
2. My DLL does not have any UI - do I need to create a hidden window or is there an easier way to create an off-screen rendering context?
3. Can I create a grayscale PBO by using GL_RED_8UI format? Will both cuda and gl be happy with that? I read the opengl interop section in the cuda programming manual and it said GL_RGBA_8UI was only usable by pixel shaders because it was an OpenGL 3.0 feature, but I didn't know if that applied to a 1-channel format. 1 channel float would also work for my purposes.
4. I thought this would be fairly easy to do - does it really require hundreds of lines of code?
Edit:
I have code to create an OpenGL context attached to a HBITMAP. Should I create a bitmap-rendering context and then try to attach a PBO to that? Or will that slow me down by also rendering to CPU memory? Is it better to create an invisible window and attach the PBO to that? Also, does the pixel format of my PBO have to match the window/bitmap? What about the dimensions?
Thanks,
Alex
There's actually an example of how to use OpenGL and CUDA together. Look at the SimpleGL example.
You may want to take a look at this example:
https://github.com/nvpro-samples/gl_cuda_interop_pingpong_st

Resources