Ask Your Question
-2

Save image using dialog

asked 2017-04-08 15:29:20 -0600

Vadim gravatar image

updated 2017-04-09 11:49:28 -0600

Hello,I tried to use GetOpenSaveName diaog , but it didn't work,how to fix it? Any Idea?

and code

int SaveAs(HWND hWnd) {

ZeroMemory(&saveSzFile, sizeof(saveSzFile));

ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = hWnd;
ofn.hInstance = hInst;
ofn.lpstrFilter = L"Bitmap files(*.bmp)\0 * .bmp\0JPEG files(*.jpg)\0 * .jpg\0All files(*.*)\0 * .*\0\0";;
ofn.lpstrCustomFilter = saveSzFile;
ofn.nMaxCustFilter = sizeof(saveSzFile);
ofn.nFilterIndex = NULL;
ofn.lpstrFile = saveSzFile;
ofn.nMaxFile = sizeof(saveSzFile);
ofn.lpstrFileTitle = NULL;
ofn.nMaxFileTitle = 0;
ofn.lpstrInitialDir = NULL;
ofn.lpstrTitle = 0;
ofn.Flags = OFN_FILEMUSTEXIST;
ofn.nFileOffset = 0;
ofn.nFileExtension = 0;
ofn.lpstrDefExt = NULL;
ofn.lCustData = NULL;
ofn.lpfnHook = NULL;
ofn.lpTemplateName = NULL;

wcstombs(savefilename, saveSzFile, sizeof(savefilename));



if (GetSaveFileName(&ofn))
{

    cvSaveImage(savefilename, dst);

}

return 0;

And actually cvSaveImage() includes only char-adress to file,i write it into savefilename,but it doesn't work and i don't know why

Thank for help in advance!

edit retag flag offensive close merge delete

Comments

apologies for deleting this question but we really don't' want you to mislead noobs here thinking, that any of this is a valid idea in 2017

berak gravatar imageberak ( 2017-04-09 02:11:36 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2017-04-08 20:08:43 -0600

berak gravatar image

if you're on windows, this functionality is already builtin, just use CTRL+s, on the window to invoke a save dialog.

also please DONT try to abuse opencv's no more maintained C-api (cvSaveImage, IplImage)

edit flag offensive delete link more

Comments

But i don't use C , I'm using c++

Vadim gravatar imageVadim ( 2017-04-09 11:29:02 -0600 )edit

Also,I do new project with using winapi, and my program doesn't have "already builtin functions",thats why i'm asking about using "Save as " dialog in opencv.

Vadim gravatar imageVadim ( 2017-04-09 11:35:55 -0600 )edit

And also i'm using "GetOpenFileName" dialog , and it's working correctly ,i think,if dialog with file opening works correctly,it can be used with "GetSaveFileName". Am i right ? Amn't I ?

Vadim gravatar imageVadim ( 2017-04-09 11:41:58 -0600 )edit

Hello,i've alreay done my project,and I did what i want,so you wasn't right bro.

P.S. Go fuck yourself,scumbag

Vadim gravatar imageVadim ( 2017-04-11 13:51:52 -0600 )edit

pleasure, as always.

(no i'm not your bro)

berak gravatar imageberak ( 2017-04-11 13:56:34 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2017-04-08 15:29:20 -0600

Seen: 381 times

Last updated: Apr 09 '17