// PROGRAM: TestReadSavePng.cexe // Test program for ReadSavePng.fp // Creates a knob control and saves it to a PNG file // Then reads it from the file and displays it into a picture window #include #include #include "ReadSavePng.h" int Pnl=0; void SavePng(void) { int Pnl, CtrlKnob; Pnl = NewPanel (0, "Test - Save to Png", 30, 30, 150, 150); DisplayPanel(Pnl); CtrlKnob = NewCtrl (Pnl, CTRL_NUMERIC_KNOB, "Knob", 25, 30); Png_SetParameters (1, 0, 72, Z_DEFAULT_COMPRESSION, 0); Png_SetTextTitle("Knob", 0); Png_SetTextAuthor("Guillaume Dargaud", 0); Png_SetTextDescription("Knob from LabWindows/CVI User interface", 1); Png_SetTextComment("Test of the ReadSavePng library", 1); Png_SavePanelControlToFile(Pnl, 0, "Test.png"); MessagePopup("Image Saved", "Click [OK] to continue."); DiscardPanel(Pnl); } void ReadPng(void) { int Pnl, Picture, Title, Author, Description, Comment; Pnl = NewPanel (0, "Test - Read From Png", 0, 0, 300, 300); DisplayPanel(Pnl); Picture = NewCtrl (Pnl, CTRL_PICTURE, "", 0, 0); SetCtrlAttribute (Pnl, Picture, ATTR_FIT_MODE, VAL_SIZE_TO_IMAGE); Title = NewCtrl (Pnl, CTRL_TEXT_MSG, "", 240, 0); Author = NewCtrl (Pnl, CTRL_TEXT_MSG, "", 255, 0); Description = NewCtrl (Pnl, CTRL_TEXT_MSG, "", 270, 0); Comment = NewCtrl (Pnl, CTRL_TEXT_MSG, "", 285, 0); Png_ReadControlFromFile(Pnl, Picture, 0, "Test.png"); SetCtrlVal(Pnl, Title, Png_GetTextTitle()); SetCtrlVal(Pnl, Author, Png_GetTextAuthor()); SetCtrlVal(Pnl, Description, Png_GetTextDescription()); SetCtrlVal(Pnl, Comment, Png_GetTextComment()); MessagePopup("Image read", "Click [OK] to exit."); DiscardPanel(Pnl); } int main (int argc, char *argv[]) { SavePng(); ReadPng(); return 0; }