How to fade a part of an object or image in corona sdk when move it? - object

I have a question in corona sdk. I need to fade top part of an object (like 60px of 250px) when moving the object to top before it goes out of the screen.
In another word, I need to set a display area for an image or object which its height is more than screen height. Like a top padding space which image will be faded when moving out of the display area (not the screen area)
Any tutorial or suggestion?

Sounds like image masks are exactly what you need.
In your case you would need to set the mask when moving the object to top, unset it when it comes back.
You can check the documentation for masks here:
http://docs.coronalabs.com/guide/media/imageMask/index.html

Related

Using tk.Scrollbar to update images in tk.canvas

I developed a small tkinter GUI to display (and export) images stored in a proprietary format. I managed to load the data into a 3D numpy uint8 array. I want to display one slice of that 3D array in a tkinter.canvas. To do so I used ImageTk.PhotoImage.
Underneath the Canvas I inserted a tk.Scrollbar. My goal is to use that scrollbar to let the user actively "scroll" though the 3D Array. Basically when the slider is moved or any of the arrows is pressed the slice corresponding to the slider position should be displayed in the canvas.
Right now I have the issue that I don't understand how to set the range of the scrollbar to my z-Dimension and then how to bind the scrollbar events to the movement or arrow actions to update the canvas.
Right now I don't have example code since this is a more conceptual problem.
Could you point me in the right direction how to solve this?
Best TMC
edit: Photo
Tkinter Gui with Canvas and Scrollbar
The solution is to use tkinter.Scale instead of tkinter.Scrollbar . As a side note, the command within:
scale = tk.Scale(yourTkFrame, from_=min, to=max, orient='horizontal', command=doSomething)
passes two values to the function doSomething.
Using the Scale allows to use the scale.get() method to retrieve the position between min and max values. Those can then be used to set the image corresponding to the selected position on the slide.

vtkImageViewer2 not rendering until I reset

I've showed a dicom image successfully with vtkImageviewer. Then I realized that vtkImageviewer2 would be more suitable, as I needed interactors and load images with slices, maybe 3d, etc
So I changed to vtkImageviewer2. Then I just see a white image. All white.
But my surprise was that, adding the render window interactor, when I press r... the image appears! So I looked into the class code. I saw the reset event and how it sets color window and color level. I've tried doing this, with poor results.
Why do I have to reset the window/level to see the image? I can do zoom, and rotate... around the white plane.
I did a widget->Update() or a imageViewer->Render() with the same result.
The Window Width/Level value is not computed initially, the default values are W255/L127.
It is necessary to set appropriate values. i.e. from Dicom Header Information or compute them by yourself.
myVtkImageViewer2->SetColorWindow(myWidthValue);
myVtkImageViewer2->SetColorLevel(myLevelValue);
Setup window/level values from your vtkImageActor:
vtkImageActor->GetProperty()->SetColorWindow(20);
vtkImageActor->GetProperty()->SetColorLevel(10);

Zoom into picture

I have this picture which I want to display into JavaFX application.
I tested to use setFitHeight and setFitWidth but the image is shrink. I want to zoom the original picture and display only the center of the image keeping the original size. Is this possible?
Define a viewport in an ImageView.

Ignoring touches on transparent areas cocos2dx

I have an image of size 480x800 pixels and there is a icon on one corner which I need to place. What I want is that to ignore all touches on the transparent areas and detect only the area where the icon is.
I found a solution in SO to this problem but it just tells the code to be used. I need to know exactly where to put that code since I am a beginner and don't know much about cocos2d so I expect a step by step solution.
Cocos2d 2.0 - Ignoring touches to transparent areas of layers/sprites
Do not use glReadPixels because it affected by bugs in android drivers. You can translate CCTouch to CCPoint in image coordinates using convertTouchToNodeSpace, and read image pixel at given point.
Create CCImage from file that contains semi-transparent picture, and read one pixel at tap point; it should be {0,0,0,0} for transparent area.
Don't forget to check that tap is not outside picture, and create pixel index in CCImage::getData() array with formulae unsigned index = x * imageWidth + y.

Incorrect coordinates retrieved from image using ABBYY OCR SDK

I'm trying to process an image using ABBYY OCR SDK using the sample code placed in this question but I'm not able get the co-ordinates right for a specific word say "OCR" on the screenshot below.
I want to draw an overlay (yellow rectangle over the word "OCR") and sometimes the rectangle is placed very far away from the actual word.
The XML you get is synthesised according to this schema.
For each recognized character it will contain an instance of charParams element as shown in the answer you linked to. The element will contain the coordinates in page pixels - the same XML also contains a page element:
<page width="..." height="..." resolution="..." originalCoords="...">
where the image width and height are stored. So l and r for each charParams element is in range 0..width-1 of the corresponding page and t and b for each charParams element is in range 0..height-1 of the corresponding page.
Also it's worth mentioning explicitly that all coordinates are in pixels - they are completely resolution-agnostic. This is why whenever you try to highlight anything on an image you have to take zoom into account - the image will likely not be always displayed as is by your device software, but will be downscaled and so you have to map page coordinates onto your zoomed-out image coordinates and highlight appropriately.
Have you checked the DPI of the original image and also check the documentation to make sure the OCR engine is using the same DPI and not returning the image in points or some other measurement system.
It could be that rectangle you are drawing in iOS is not based on pixels but on some other measurement system also.
You just need to work through the process, testing as you go, and work out where the problem is coming from. It is most likely a uniform scaling and the distance from the actual word is proportional to the distance of the word from the top left of the page.

Resources