Ask Your Question
-2

Save image using dialog

asked Apr 8 '17

Vadim gravatar image

updated Apr 9 '17

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!

Preview: (hide)

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 (Apr 9 '17)edit

1 answer

Sort by » oldest newest most voted
1

answered Apr 9 '17

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)

Preview: (hide)

Comments

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

Vadim gravatar imageVadim (Apr 9 '17)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 (Apr 9 '17)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 (Apr 9 '17)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 (Apr 11 '17)edit

pleasure, as always.

(no i'm not your bro)

berak gravatar imageberak (Apr 11 '17)edit

Question Tools

1 follower

Stats

Asked: Apr 8 '17

Seen: 391 times

Last updated: Apr 09 '17