LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Canvas and image process

Hello,

I use Adobe Illustrator drawing a curve , then export it in .emf format .Now load the image into canvas control ,but can not see the total profile . Please give an advise how to adjust the control so that it can show the total image ? and also , how to zoom in an image ? Thanks.

David
0 Kudos
Message 1 of 10
(4,917 Views)
Hello David,

I dont think you can do zoom on canvas in CVI, but you can write your own code to do that. Take the bitmap from the canvas and increase/decrease the array size using some algorithm and then display it back on the canvas.

As for the EMF file, it should be displayed properly on the canvas. When you use Load image in the control confg, it makes the size of control equal to the size of the image. If the image is lot bigger it goes outside the panel. If you can attach the emf file, maybe I can look more into it.

The following link might be helpful if you have a problem with the text display in emf file:
Adobe EMF Problem in Microsoft Windows

I hope it helps,
Rajiv
0 Kudos
Message 2 of 10
(4,915 Views)
Hi RajivG,

The attachment is a segment road diagram . I just want to simulate a track run along with the line , please give an advise how to do this . Your advise is greatly appreciated . Thanks.

David
0 Kudos
Message 3 of 10
(4,915 Views)
Hello David,

I was able to load the image on the Canvas as well as a Image control by resizing the control manually to see it on the panel.

As for having a track run along with the line, I think canvas might be a good option. All you need to do is after loading the image in the canvas, read the canvas in bitmap (GetCtrlBitmap) and change the bitmap to show the track (CanvasDrawBitmap). If you want some kind of animation, you can continuously change an area of bitmap and show it on the canvas. There are various canvas and bitmap functions in CVI that you can use.

Do let me know if you come accross some problem by explaing your application and the error in little more detail.

I hope it helps,
Rajiv
0 Kudos
Message 4 of 10
(4,915 Views)
Hi Rajiv,

Thank you for your reply! Due to it is first programming the image ,could you show me a demo ? I want to simulate a track which runs along the road .Your advise is greatly appreciated .

David
0 Kudos
Message 5 of 10
(4,915 Views)
Hello David,

You can find some example relating to animation in the shipped examples. You can search for "animation" in the CVI Example Finder to find the two examples animsample.prj and picture.prj

These examples can also be found at
\Program Files\National Instruments\CVI71\samples\userint\custctrl\animate\animsample.prj
and
\Program Files\National Instruments\CVI71\samples\userint\picture.prj

These example programs wil give you some idea on how to create a simple animation in CVI. Also, like we discussed earlier, you can always create a new algorithm that will do the animation like changing a bitmap.

I hope it helps,
Rajiv
0 Kudos
Message 6 of 10
(4,915 Views)
Rajiv,

Since the bitmap is as a background on the canvas , and the line or curve is not in regular . I need to determine the variety trend of the road , then generate a truck at the corresponding position to identify the block status . How to do this ? Your advise is highly appreciated . Thanks.


David
0 Kudos
Message 7 of 10
(4,915 Views)
Hello David,

For your reference, I am attaching a demo that animates one bmp on another bmp. The demo uses a small Car that run on the Road. I have tried to keep the coding very simple and hope you will have no trouble understanding some of the CVI Bitmap function.

It is not our normal practice to provide these codes, but hope it will help you solve the problem at hand.

I hope it helps,
Rajiv
0 Kudos
Message 8 of 10
(4,915 Views)
Hi Rajiv,

Thank you for your reply. For a line type road, it is simple to solve , but if there is a curve or an arc type road , how to simulate the car running status ? Thanks .

David
0 Kudos
Message 9 of 10
(4,918 Views)
Hello David,

Since you have the animation, all you need to do for a custom trajectory is apply a mathematical equation to giving you a value x and y.

For example:
CanvasDrawBitmap (panelHandle, PANEL_CANVAS, bitmapIDa,
MakeRect(0, 0, CARHEIGHT, CARWIDTH),
MakeRect((canvasHeight/2)-(CARHEIGHT/2)+j, i, CARHEIGHT, CARWIDTH));
ProcessDrawEvents ();
Delay (0.01);
CanvasDrawBitmap (panelHandle, PANEL_CANVAS, bitmapID,
MakeRect((canvasHeight/2)-(CARHEIGHT/2)+j, i, CARHEIGHT, CARWIDTH),
MakeRect((canvasHeight/2)-(CARHEIGHT/2)+j, i, CARHEIGHT, CARWIDTH));
if (flag == 0)
{
if (j<30) {j=j+2;}
else {flag=1;}
}
else
{
if (j>-30) {j=j-2;}
else {flag=0;}
}


The above code (a modification of the previous code) creates a triangular wave motion of the car. I am sure that you can create the mathematical equation of the motion and use it for the animation you are looking for.

Rajiv
Message 10 of 10
(4,903 Views)