LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Load image into Program and manipulate

i didn't see any examples nor and posts on the forum.

 

Would like to load a picture (jpg, bmp, possibly png) into a control.  it seems a picture control is best for this.  However, I would like the user to be able to manipulate the picture, so rotate, resize it, etc which is not available in with the picture control.  Any ideas? Currently i just have the image load into the picture control and have movable splitters that resize it.

0 Kudos
Message 1 of 3
(3,666 Views)

I am afraid native CVI libraries do not have the functionality you need here.

 

You can code your own image processing routines, if you do not need complicated operations on them, or use a 3rd party library.

 

NI also has some image processing libraries. If you already have them, they will probably suit your needs.

There also many -some free- libraries like Intel IPL (not updated anymore), OpenCV, etc... 

S. Eren BALCI
IMESTEK
0 Kudos
Message 2 of 3
(3,656 Views)

Seems i have been able to do want I want (for the most part) by just using a Picture Ring and loading files into that list.  upon loading and changing picture, I resize the picture so it fits within the panel.  My code is below:

 

This is also called from the load_image callback that essentially passes the width and height in the event data when calling CallCtrlCallback ... 

 

int CVICALLBACK PICTURE_CHANGE (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { int index, picID,iWidth,iHeight,maxControlWidth,maxControlHeight; double temp; switch (event) { case EVENT_COMMIT: if (!((eventData1 > 0) && (eventData2 > 0))) { GetCtrlIndex (notes_handle, NOTES_FORM_PICTURE, &index); GetCtrlBitmap (notes_handle, NOTES_FORM_PICTURE, index, &picID); GetBitmapData (picID, NULL, NULL, &iWidth, &iHeight, NULL, NULL, NULL); } else { iWidth = eventData1; iHeight = eventData2; } GetCtrlAttribute(notes_handle,NOTES_FORM_PICTURE,ATTR_LEFT,&maxControlWidth); GetCtrlAttribute(notes_handle,NOTES_FORM_PICTURE,ATTR_TOP,&maxControlHeight); maxControlHeight = tab_size.height - maxControlHeight - maxControlWidth; //Ensure doesn't go past bottom and same margin as on left is on bottom maxControlWidth = tab_size.width - (2*maxControlWidth); //Ensure doesn't exceed outside boundaries and centered if (maxControlHeight < iHeight) { temp = (double)maxControlHeight/(double)iHeight; iWidth = temp*iWidth; iHeight = maxControlHeight; } if (maxControlWidth < iWidth) { temp = (double)maxControlWidth/(double)iWidth; iHeight = temp*iHeight; iWidth = maxControlWidth; } SetCtrlAttribute(notes_handle,NOTES_FORM_PICTURE,ATTR_WIDTH,iWidth); SetCtrlAttribute(notes_handle,NOTES_FORM_PICTURE,ATTR_HEIGHT,iHeight); break; } return 0; }

 The issue I have now is that when the picture ring is changed to show another picture, there is a bad flicker seen by the user.  The next picture is set to the bounds of the previous one and shown to the user before i can change the size.  How can I prevent the flicker being shown to the user and only update the control/screen after i have updated the size.

 

thanks

 

0 Kudos
Message 3 of 3
(3,643 Views)