NO

Author Topic: Image Viewer Ended  (Read 10936 times)

Grincheux

  • Guest
Image Viewer Ended
« on: March 23, 2016, 11:08:03 AM »
Binaries here
Screen here

Grincheux

  • Guest
Re: Image Viewer Ended
« Reply #1 on: March 29, 2016, 08:41:33 AM »
Hello the Ghosts

Added possiblity to play with some filters on the images chanels.
Added histogram.

Grincheux

  • Guest
Re: Image Viewer Ended
« Reply #2 on: April 13, 2016, 05:19:32 PM »

Download latest version here

Some useful functions in EUPHORY. ;D

Quote
2016/04/14 - When inserting data into memory database, I use TRANSACTION, to be faster.
2016/04/13 - Added new sort options.
2016/04/13 - Added the possibility to save only the image datas.
2016/04/13 - Added "Backup Datas" to get all the informations about directory images. Created an other CSV file.
2016/04/13 - When histogram is displayed, created a CSV file with histogram data.
2016/04/13 - Added some filters effects.
2016/04/13 - Replaced "Convolove 3x3" with new effects items.
2016/04/13 - Added histogram datas to the main database.
2016/04/13 - Added "Neighbors Detection".
2016/04/04 - Reorganized main menu.
2016/04/04 - Added Rows/Cols effects.
2016/04/04 - Added Box and Cube effects.
2016/03/31 - Euphory will be the new name of the donationware version.
2016/03/31 - Removed DLL filters.
2016/03/31 - A SQLite database replace the filters dll.
2016/03/29 - Renaming ImageViewer : E4I - Effects for Images - Euphorie - Euphory.
2016/03/29 - You can copy the histogram to the clipboard.
2016/03/29 - You can save the histogram to a file.
2016/03/29 - Added Histogram Tab.
2016/03/27 - Added a filter Tab. No easy to use but reults are interesting. Can apply a diffrent filter on Red, Green, Blue Channels.
2016/03/27 - Removed generated MSVC 2015 manifest, problem using SYSLINK, but none with Pelle's.
2016/03/27 - Added Effect 10.80
2016/03/27 - Added Effect 0.88
2016/03/27 - Added Donationware link in the meu bar for "French" & "English"
2016/03/24 - Added File Name displayed on the status bar while cleaning metadas.
2016/03/24 - Modified Crop all files.
2016/03/24 - Added File Name and Path to the dialog box informations.
2016/03/24 - Changed the Find Duplicates dialog box.
2016/03/24 - Modified some dialog texts.
2016/03/23 - Added Blend Cross effect.
2016/03/23 - Synchronized images between main screen and zoom/effects.
2016/03/23 - Added Cross effect.
2016/03/21 - Added Double Mirroring effect.
2016/03/21 - Added 3D Tab.
2016/03/21 - Added Eiffel Tower effect.
2016/03/21 - Added Tilt effects.
2016/03/17 - Making sort into another temporary table rather than the same.
2016/03/17 - Added more convolution filters. For tests.
2016/03/17 - Corrected a bug in Sort option.
2016/03/17 - Corrected a bug in installer. The profile ImageViewer.ini could not be updated.
2016/03/15 - Resolved problem of spacing icons in toolbar images with the help of Timo Lähde.
2016/03/11 - Reajusted status bar display area.
2016/03/11 - Corrected minor bugs.
2016/03/11 - Corrected sources files for MSVC2015 and Pelle's C Compiler give the same results.
2016/03/11 - Added C/C++ runtime dll into installation package.
2016/03/11 - Corrected bug in Sort function.
2016/03/11 - Added effect Java Niaise.
2016/03/10 - Corrected some bugs.
2016/03/10 - Added save option for layers.
2016/03/10 - Added Copy to clipboard for layers.
2016/03/10 - Added new fusion modes.
2016/03/08 - Added a kind of layers.
2016/03/07 - Added Colors files (140 files).
2016/03/05 - Added textures of my own.
2016/02/26 - Added CoolMenu (Owner drawn menu adapted by Mike Caetano 1/2002 - from source by James Brown,catch22.uk.net)
2016/02/26 - Added 128 undo levels for Memory option.
2016/02/26 - Added Memory option.
2016/02/26 - Added Rotate option.
2016/02/23 - Added 10 new effects
2016/02/22 - Some bugs corrected
2016/02/22 - Changed the Gallery with free images
2016/02/22 - Changed the site presentation with free images (Common Wiki or CopyLeft).
2016/02/22 - Added five vertical mirrors.
2016/02/21 - Added copy image to clipboard.
2016/02/21 - Added copy effect to clipboard.
2016/02/21 - Added auto cropping option.
2016/02/21 - Added functions for removing metadatas.
2016/02/21 - Added count colors options.
2016/02/21 - Modified main menu
2016/02/21 - Added filter : Laplace
2016/02/20 - Added filter : Kirsch
2016/02/20 - Added filter : Robinson
2016/02/20 - Added filter : Prewitt
2016/02/20 - Added filter : Sobel
2016/02/20 - Added eight filters that I did myself.
2016/02/20 - Added contours detection
2016/02/20 - Made only one archive and only one installer.
2016/02/20 - Merged the two projects under the same folder.
2016/02/20 - Corrected big bugs in grey levels conversion.
2016/02/19 - Added Gray levels.
2016/02/19 - Modified Main Menu.
2016/02/19 - Added Horizontal & Vertical Mirror.
2016/02/19 - Created a version for Visual Studio Community 2015.
2016/02/18 - Use double buffer for drawing icons.
2016/02/18 - Replace the highlight icons with colored border.
2016/02/18 - Added a tab for real size effect image.
2016/02/18 - Added a tab for real size image.
2016/02/18 - First release available.
2016/02/14 - A preview is available.
2016/01/23 - Start writting program.
« Last Edit: April 13, 2016, 05:21:05 PM by Grincheux »

JohnF

  • Guest
Re: Image Viewer Ended
« Reply #3 on: April 13, 2016, 07:27:24 PM »
You have been busy, I've never seen a project completed so quickly.

Are you pleased with it?

John

Grincheux

  • Guest
Re: Image Viewer Ended
« Reply #4 on: April 13, 2016, 08:18:04 PM »
This image makesme pretty. Thank you me.
I am very pleased and always have new ideas.
Now I would like to make some 3D with images.
For the instant I am creating filters. I have to create 387 420 488 filters. Happily I made an option that deletes similar images...
I have 66 folders with 100 SQLite files per folder.
I use two compilers: MSVC and Pelles. Pelles is the best between the two. It find errors that MS does not detect.
I have three warnings that I don't understand.
Quote
C:\Users\Grincheux\Documents\Visual Studio 2015\Projects\Euphory\Sqlite.c(218): warning #2154: Unreachable code.
C:\Users\Grincheux\Documents\Visual Studio 2015\Projects\Euphory\Sqlite.c(645): warning #2154: Unreachable code.
C:\Users\Grincheux\Documents\Visual Studio 2015\Projects\Euphory\Sqlite.c(767): warning #2154: Unreachable code.
When the program runs It uses these functions without any problem.
Yestirday I resolved one warning but here I can't.

Might I ask you to read the following page; http://ivw.phrio.biz/Some_useful_functions
Because I had to use Google Translate, I made some corrections but it you stay any errors.

Thanks.

Philippe ;)
« Last Edit: April 13, 2016, 08:27:21 PM by Grincheux »

JohnF

  • Guest
Re: Image Viewer Ended
« Reply #5 on: April 14, 2016, 08:26:10 AM »
Post the parts that trouble you here, I can't help today but maybe someone else will help.

John

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 2113
Re: Image Viewer Ended
« Reply #6 on: April 14, 2016, 09:11:57 AM »
I use two compilers: MSVC and Pelles. Pelles is the best between the two. It find errors that MS does not detect.
I have three warnings that I don't understand.
Quote
C:\Users\Grincheux\Documents\Visual Studio 2015\Projects\Euphory\Sqlite.c(218): warning #2154: Unreachable code.
C:\Users\Grincheux\Documents\Visual Studio 2015\Projects\Euphory\Sqlite.c(645): warning #2154: Unreachable code.
C:\Users\Grincheux\Documents\Visual Studio 2015\Projects\Euphory\Sqlite.c(767): warning #2154: Unreachable code.

These messages means that in your code there are some conditional parts which conditions can be solved statically at compile time. So the compiler detects that the code could "never be reached" because the condition will never be true and remove it as dead code.
I.e. consider following chunk:
Code: [Select]
const int a=1;
void foo(void)
{
if (a == 0)
printf("a is zero!\n");
}
It will give " warning #2154: Unreachable code." because 'a' is constant and always !=0, so the condition in the if is never satisfied and the conditional code will never be executed (unreachable).
"It is better to be hated for what you are than to be loved for what you are not." - Andre Gide

Grincheux

  • Guest
Re: Image Viewer Ended
« Reply #7 on: April 14, 2016, 10:44:07 AM »
Yes Frankie, I agree, I found such an error two days ago with a null pointer. I set it to NULL and after I test it! But here, no idea.
I join my source code. MSVC does not help me to resolve it, normal it's a BLIND compiler

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 2113
Re: Image Viewer Ended
« Reply #8 on: April 14, 2016, 12:27:39 PM »
Grincheux the code you posted is huge. Please restrict it to a compilable sample.
At least let us know which lines give the warning.
"It is better to be hated for what you are than to be loved for what you are not." - Andre Gide

Grincheux

  • Guest
Re: Image Viewer Ended
« Reply #9 on: April 14, 2016, 02:46:01 PM »
The first THREE lines tell where the error is.

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2115
Re: Image Viewer Ended
« Reply #10 on: April 14, 2016, 03:19:32 PM »
Partial code for SQLite_GetFileName for test with or without optimization.
Code: [Select]
PellesForum2.c(30): warning #2154: Unreachable code.
May the source be with you

Grincheux

  • Guest
Re: Image Viewer Ended
« Reply #11 on: April 14, 2016, 04:07:49 PM »
A big mystery. Thank you for making a new project

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 2113
Re: Image Viewer Ended
« Reply #12 on: April 14, 2016, 06:12:24 PM »
The warning correctly comes from the inlining of the strsafe functions, specifically StringCchCopy().
The compiler, without any more spec, inlines a local definition for specific safe string functions. In your case you use StringCchCopy() that is defined, in strsafe.h, as:

Code: [Select]
#ifndef STRSAFE_NO_CCH_FUNCTIONS
#ifdef STRSAFE_INLINE
STRSAFEAPI StringCchCopyA(char *pszDest, size_t cchDest, const char *pszSrc)
{
    if (cchDest > STRSAFE_MAX_CCH)
        return STRSAFE_E_INVALID_PARAMETER;
    else
        return StringCopyWorkerA(pszDest, cchDest, pszSrc);
}

...

#ifdef STRSAFE_INLINE
STRSAFEAPI StringCopyWorkerA(char *pszDest, size_t cchDest, const char *pszSrc)
{
    HRESULT hr = S_OK;

    if (cchDest == 0)
    {
        hr = STRSAFE_E_INVALID_PARAMETER;
    }
    else
    {
        while (cchDest && *pszSrc != '\0')
        {
            *pszDest++ = *pszSrc++;
            cchDest--;
        }

        if (cchDest == 0)
        {
            pszDest--;
            hr = STRSAFE_E_INSUFFICIENT_BUFFER;
        }

        *pszDest= '\0';
    }

    return hr;
}

...

In your code you use always constants for max string length when calling StringCchCopy():

Code: [Select]
//C:\Users\Grincheux\Documents\Visual Studio 2015\Projects\Euphory\Sqlite.c(218): warning #2154: Unreachable code.
LPSTR SQLite_GetFileName(int __iItem,LPSTR __lpszFileName)
{
StringCchCopy(__lpszFileName,MAX_PATH,(LPSTR) sqlite3_column_text(_hStatement,0)) ;
...

//C:\Users\Grincheux\Documents\Visual Studio 2015\Projects\Euphory\Sqlite.c(645): warning #2154: Unreachable code.
int SQLite_Sort(HWND __hWnd,int _iId)
{
if(szCurrentFile[0] == '\0') StringCchCopy(szCurrentFile,MAX_PATH,_lpszImg) ;
...
StringCchCopy(szCurrentDialogFile,MAX_PATH,_lpszImg) ;
...
if(_szFirstFile[0] == '\0') StringCchCopy(szCurrentFile,MAX_PATH,_lpszImg) ;
...
StringCchCopy(szCurrentFile,MAX_PATH,_szFirstFile) ;
...

//C:\Users\Grincheux\Documents\Visual Studio 2015\Projects\Euphory\Sqlite.c(768): warning #2154: Unreachable code.
void SQLiteDB_BackupToCsv(HWND __hWnd)
{
...
StringCchCopy(_szTmp1,sizeof(_szTmp1),"\"Item\";\"Image\";\"lParam\";\"FileSize\";\"ImgSize\";\"ImgWidth\";\"ImgHeight\";\"ImgRatio\";\"MedianRed\";\"MedianGreen\";\"MedianBlue\";\"NumRed\";\"NumGreen\";\"NumBlue\";\"MaxRed\";\"MaxGreen\";\"MaxBlue\";\"AnalyzedColors\";\"NumberOfUniqueColors\";\"FileMD5\";\"ImgMD5\";\"CurrentFile\"\n") ;
...
StringCchCopy(_szTmp1,sizeof(_szTmp1),"An error occured during backup operation") ;
...

For this reason when inlining the function StringCopyWorkerA() happen that the first check is constant so the conditional code is never used:

Code: [Select]
STRSAFEAPI StringCopyWorkerA(char *pszDest, size_t cchDest, const char *pszSrc)
{
    HRESULT hr = S_OK;

    if (cchDest == 0)    //if cchDest  is a constant and always !=0
    {
        hr = STRSAFE_E_INVALID_PARAMETER;    //This code will never execute, so it is **unreacheble**!!!!
    }

As a check replace the main function in the project provided by Timo with the following:

Code: [Select]
LPSTR SQLite_GetFileName(int __iItem,LPSTR __lpszFileName)
{
sqlite3_stmt *_hStatement ;
LPSTR _lpszErrorMessage ;
char _szTmp[1024] ;
volatile int max = MAX_PATH;

if(!__lpszFileName)
return (NULL) ;

*__lpszFileName = '\0' ;

StringCbPrintf(_szTmp,sizeof(_szTmp),szSQL_GetFileName,__iItem) ;

if(sqlite3_prepare_v2(hSQLite,(const char *) _szTmp,-1,&_hStatement,(const char **) &_lpszErrorMessage) != SQLITE_OK)
return (NULL) ;

while(sqlite3_step(_hStatement) == SQLITE_ROW)
//StringCchCopy(__lpszFileName,MAX_PATH,(LPSTR) sqlite3_column_text(_hStatement,0)) ;
StringCchCopy(__lpszFileName,max,(LPSTR) sqlite3_column_text(_hStatement,0)) ;

sqlite3_reset(_hStatement) ;
sqlite3_finalize(_hStatement) ;

return (__lpszFileName) ;
}

Note the volatile variable max that tells the compiler to not assume that the value will be constant. In this case the condition if (cchDest == 0) cannot be resolved at compile time, the conditional code must be generated and the warning is not issued.
« Last Edit: April 14, 2016, 06:19:39 PM by frankie »
"It is better to be hated for what you are than to be loved for what you are not." - Andre Gide

Grincheux

  • Guest
Re: Image Viewer Ended
« Reply #13 on: April 14, 2016, 06:44:54 PM »
Quote
Building 3D.obj.
Building About.obj.
Building Api_Borders.obj.
Building Api_Convolve.obj.
Building Api_Datas.obj.
Building Api_Effects.obj.
Building Api_Flou.obj.
Building Api_Functions.obj.
Building Api_IDCat.obj.
Building Api_Mirror.obj.
Building Api_Red.obj.
Building Api_Rotate.obj.
Building Api_Sort.obj.
Building Apr_Grey.obj.
Building Calques.obj.
Building Clipboard.obj.
Building Colors.obj.
Building CoolMenu.obj.
Building Cube.obj.
Building Datas.obj.
Building Dll_Effects.obj.
Building DonationWare.obj.
Building Effects.obj.
Building Euphory.obj.
Building Euphory.res.
Building FilterByColors.obj.
Building Filters_All.obj.
Building Filters_Dialog.obj.
Building Filtres.obj.
Building Histogramme.obj.
Building Icones.obj.
Building Images.obj.
Building ImagesToolBar.obj.
Building Incline.obj.
Building Incline2.obj.
Building Infos.obj.
Building Layer_Fusion.obj.
Building Layer_Paint.obj.
Building Layers.obj.
Building md5.obj.
Building Memory.obj.
Building Metadatas.obj.
Building Profile.obj.
Building Sqlite.obj.
Building Utils.obj.
Building Zoom.obj.
Building PEuphory.exe.
Successfully signed and timestamped 'PEuphory.exe'
Done.

I would never have found. Great work!
« Last Edit: April 14, 2016, 06:55:52 PM by Grincheux »

Grincheux

  • Guest
Re: Image Viewer Ended
« Reply #14 on: April 14, 2016, 07:00:51 PM »
Now it's OK but I don't understand what you told.

I had replaced the CONSTANT with a sizeof, alway the same problem but with your solution it's clean.
I never had used STRSAFE, I made it once, this is the last!

Quote
volatile int sizeof_Tmp1 = sizeof(_szTmp1) ;
StringCchCopy(_szTmp1,sizeof_Tmp1,"\"Item\";\"Image\";\"lParam\";\"FileSize\";\"ImgSize\";\"ImgWidth\";\"ImgHeight\";\"ImgRatio\";\"MedianRed\";\"MedianGreen\";\"MedianBlue\";\"NumRed\";\"NumGreen\";\"NumBlue\";\"MaxRed\";\"MaxGreen\";\"MaxBlue\";\"AnalyzedColors\";\"NumberOfUniqueColors\";\"FileMD5\";\"ImgMD5\";\"CurrentFile\"\n") ;