Hey folks,

I need a program that can do a few things I need for work. I could not find one so I decided to write one in assembly.
It has to be able to:
-Resize jpg's
-put a text string on each picture like "my images"
-output the pictures in several folders and sort them by date.
I guess i could do this by a Corel Photopaint Macro but it is more interesting to do it in assembly. I just need to know where to get started. I looked around on the board here and found a whole bunch of stuff about loading them, but not editing them.

Thanx in advance,
Olli
Posted on 2002-06-05 15:02:13 by Olli
I think your best bet is to load the Jpeg and convert to a DIB (use one of the free libraries) then read in you overlay DIB, then using a set colour as a mask place you overlay onto your main picture

Next resave as a jpeg

to scale your DIB there are a couple of methods, i would recommend placing your overlay on first then rescaling
Posted on 2002-06-05 15:21:57 by Terab
I downloaded the latest version of Intel's jpg library.
I quiet sure i have to load the library now. But how do i get the jpg file on the disc converted to dib in a memory block and overlay my text string ? How do i know the functions of the library ?
Please don't forget I'm new to working with libraries and image files. May be we could have this thread as kind of a tutorial for other people interested in working with image files like me ?
Posted on 2002-06-06 02:35:31 by Olli

I downloaded the latest version of Intel's jpg library.
Please don't forget I'm new to working with libraries and image files. May be we could have this thread as kind of a tutorial for other people interested in working with image files like me ?


I prefer the freeimage dll, just find it easier to use and has a lot more functions, it is a bit bigger but well worth it.

I posted a message in another thread on how to load the library, I dont know if the moderators like cross posting? Check the other thread related to jpegs.

The freeimage library has the ability to load and convert the image for you - so read jpg tell it you want a DIB and its all done for you


check the masm examples for how to load a dll
Posted on 2002-06-06 02:47:17 by Terab
Olli,
take a look at the source code section of Iczelions site. There is an example for using the Intel JPEG Library.

http://win32asm.cjb.net
Posted on 2002-06-06 02:47:19 by bazik
Great,

thanks a lot...
I got a working application that opens and saves jpg images, ur posts helped me alot here. What i dont get to work is to show the jpg in a dialogbox. I read Ernie's tutorial to show jpgs but i don't understand. Isn't there a much simpler way to show the image before i save it? I mean after i loaded it with FreeImage.dll i shouldn't be much of a problem to show it because it is in memory already. Am I right? I just don't know how to show it in a dialog box.

Thanks in advance,
Olli
Posted on 2002-06-06 07:44:55 by Olli

I mean after i loaded it with FreeImage.dll i shouldn't be much of a problem to show it because it is in memory already. Am I right? I just don't know how to show it in a dialog box.

Thanks in advance,
Olli


Well you should have a handle to a DIB, now you could place the bitmap on the dialog box.

Easier maybe to place it onto a static control - then you can use something like:

invoke SendMessage,hStatic1,BM_SETIMAGE,0,hDIB

you might need to convert the DIB to a compatible form for the DC first

hope this helps
Posted on 2002-06-06 07:59:11 by Terab
Never tried one of these librarys myself :)

So my question: Can you also crop/resize the pictures with it?
I want to convert a screenshot of the entire screen to a jpeg.
Posted on 2002-06-06 08:02:06 by bazik

Never tried one of these librarys myself :)

So my question: Can you also crop/resize the pictures with it?
I want to convert a screenshot of the entire screen to a jpeg.



Should be able to - I think I have some source code at home for it. there is a section in the MSDN which gives example API code to capture the screen into a bitmap - its in VB but easy to convert to asm


from there it is easy enough to strechblt into another place and the convert to jpeg and save
Posted on 2002-06-06 08:09:55 by Terab
So this is what i got so far to show my jpg in a static control. But i can't figure out what all the pointers in GetProcAddress have to look like. The source code of the FreeImage.dll, could it be written in C? I need some help with the pointers or even other mistakes in this source. Thanks in advance
Olli




.data
missDll db "Dll not found!",0
ImageFormat db ?
TEST_FILE db "test.jpg",0
DIB dd ?

.code
.ELSEIF uMsg==WM_INITDIALOG
invoke LoadLibrary,ADDR FreeImageDLL
.IF eax==NULL
invoke MessageBox,NULL,addr missDll,addr DlgName,MB_OK
return 0
.ELSE
mov hDLL, eax
invoke LoadProcs,hDLL
.IF eax==NULL
return 0
invoke GetProcAddress,hLibrary,ADDR f1name
mov lpFreeInitialise , eax
invoke GetProcAddress,hLibrary,ADDR f2name
mov lpFreeGetFileType , eax
invoke GetProcAddress,hLibrary,ADDR f3name
mov lpFreeLoad, eax
invoke GetProcAddress,hLibrary,ADDR f5name
mov lpFreeUnload , eax
invoke GetProcAddress,hLibrary,ADDR f6name
mov lpFreeDeInitialise, eax

push NULL
call [lpFreeInitialise]

push 0
mov eax,offset TEST_FILE
push eax
push 0
call [lpFreeLoad]

mov DIB,eax
invoke SendMessage,hStatic,STM_BITMAP,IMAGE_BITMAP,eax

push DIB
call [lpFreeUnload]
call [lpFreeDeInitialise]

.ELSE
.ENDIF
.ENDIF
Posted on 2002-06-10 15:26:09 by Olli

So this is what i got so far to show my jpg in a static control. But i can't figure out what all the pointers in GetProcAddress have to look like. The source code of the FreeImage.dll, could it be written in C? I need some help with the pointers or even other mistakes in this source. Thanks in advance

invoke GetProcAddress,hLibrary,ADDR f1name
mov lpFreeInitialise , eax
invoke GetProcAddress,hLibrary,ADDR f2name
mov lpFreeGetFileType , eax
invoke GetProcAddress,hLibrary,ADDR f3name
mov lpFreeLoad, eax
invoke GetProcAddress,hLibrary,ADDR f5name
mov lpFreeUnload , eax
invoke GetProcAddress,hLibrary,ADDR f6name
mov lpFreeDeInitialise, eax





aaaah yes - i forgot to include the f1name etc definitions in my original post (sorry)

i suppose this will help.... :)

f1name db "_FreeImage_Initialise@4",0
f2name db "_FreeImage_GetFileType@8",0
f3name db "_FreeImage_Load@12",0
f4name db "_FreeImage_Save@16",0
f5name db "_FreeImage_Unload@4",0
f6name db "_FreeImage_DeInitialise@0",0
Posted on 2002-06-10 15:31:40 by Terab
also one thing , the below code will work, but dont you want to load the library when your code first runs?

else everytime the dialog opens you will be loading the lib again.


.ELSEIF uMsg==WM_INITDIALOG
invoke LoadLibrary,ADDR FreeImageDLL
Posted on 2002-06-10 15:33:51 by Terab
Thanks that really solved the pmy problem and I'm starting to understand this whole thing. I found another problem though. You can only show BMP Resources through the STM_SETIMAGE and the BM_SETIMAGE (posted in this thread)don't work either. So i actually need a simpler way to do this. Any ideas ?
Posted on 2002-06-11 07:08:03 by Olli
That's how I show picture's on a static control in my program:


invoke CreateWindowEx, 0, addr szStaticClass, addr szInbox, ; create static
WS_CHILD or WS_VISIBLE or SS_CENTERIMAGE or SS_NOTIFY or SS_BITMAP, 0, 25, 96, 75, hCtl, OB_INBOX, 400000h, 0
mov hInbox, eax

invoke LoadBitmap, 400000h, 102 ; load image from rc file
invoke SendMessage, hInbox, STM_SETIMAGE, IMAGE_BITMAP, eax ; set the image



Perhaps your forgot the SS_BITMAP style on the static control?
Posted on 2002-06-11 07:24:46 by bazik
Can AnyOne Post A inc file for use of Freeimage dll?
I'm a newbie,and have some problem while change FreeImage.h to FreeImage.inc
Posted on 2002-06-11 09:08:48 by purefiring
No that ain't the problem. Here is my code. Remember I'm just playing around with the code this is nothing final yet. May be u see a mistake in it. I'll try to figure it out. If u are quicker please post it here.
Thanks in advance
Olli



.386
.model flat,stdcall
option casemap:none

include \masm32\include\windows.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc
include \masm32\include\gdi32.inc
include \masm32\include\masm32.inc
include \masm32\include\shell32.inc
include \masm32\include\comctl32.inc
include \masm32\include\comdlg32.inc
include \masm32\include\advapi32.inc
include \masm32\include\crypt32.inc

includelib \masm32\lib\shell32.lib
includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\gdi32.lib
includelib \masm32\lib\masm32.lib
includelib \masm32\lib\comctl32.lib
includelib \masm32\lib\comdlg32.lib
includelib \masm32\lib\advapi32.lib
includelib \masm32\lib\crypt32.lib

DlgProc PROTO :DWORD,:DWORD,:DWORD,:DWORD

.data
DlgName db "Jpgs",0
MissDll db "Dll not found!",0
TestFile db "test.jpg",0
f1name db "_FreeImage_Initialise@4",0
f2name db "_FreeImage_GetFileType@8",0
f3name db "_FreeImage_Load@12",0
f5name db "_FreeImage_Unload@4",0
f6name db "_FreeImage_DeInitialise@0",0
FreeImageDLL db "FreeImage.dll",0

.data?
hInstance HINSTANCE ?
hDLL dd ?
DIB dd ?
lpFreeInitialise dd ?
lpFreeGetFileType dd ?
lpFreeLoad dd ?
lpFreeUnload dd ?
lpFreeDeInitialise dd ?

.const
IDC_JPG equ 1001

.code
start:

invoke GetModuleHandle, NULL
mov hInstance, eax
invoke DialogBoxParam, hInstance, ADDR DlgName,NULL, addr DlgProc, NULL
invoke ExitProcess,eax

DlgProc proc hWin :DWORD, uMsg :DWORD, wParam :DWORD, lParam :DWORD

.IF uMsg==WM_COMMAND
mov eax,wParam
mov edx,wParam
shr edx,16

.ELSEIF uMsg==WM_INITDIALOG
invoke LoadLibrary,ADDR FreeImageDLL
.IF eax==NULL
invoke MessageBox,NULL,addr MissDll,addr DlgName,MB_OK
.ELSE
mov hDLL, eax
invoke GetProcAddress,hDLL,ADDR f1name
mov lpFreeInitialise , eax
invoke GetProcAddress,hDLL,ADDR f2name
mov lpFreeGetFileType , eax
invoke GetProcAddress,hDLL,ADDR f3name
mov lpFreeLoad, eax
invoke GetProcAddress,hDLL,ADDR f5name
mov lpFreeUnload , eax
invoke GetProcAddress,hDLL,ADDR f6name
mov lpFreeDeInitialise, eax

push NULL
call [lpFreeInitialise]

push 0
mov eax,offset TestFile
push eax
push 0
call [lpFreeLoad]

mov DIB,eax
invoke GetDlgItem,hWin,IDC_JPG
.IF eax==NULL
invoke MessageBox,NULL,addr MissDll,addr DlgName,MB_OK
.ELSE
invoke SendMessage,eax,STM_SETIMAGE,IMAGE_BITMAP,DIB

push DIB
call [lpFreeUnload]
call [lpFreeDeInitialise]
.ENDIF


.ENDIF
.ELSEIF uMsg==WM_CLOSE
invoke EndDialog,hWin,NULL
.ENDIF
ret
DlgProc endp
end start

--------------------------------------------------------
Resource
--------------------------------------------------------


#include "\masm32\include\resource.h"

#define IDC_JPG 1001

Jpgs DIALOG LOADONCALL PURE 10, 10, 500, 400
STYLE 0x0004 | DS_CENTER | WS_CAPTION | WS_MINIMIZEBOX |
WS_SYSMENU | WS_VISIBLE | WS_OVERLAPPED | DS_MODALFRAME | DS_3DLOOK
CAPTION "Easy Jpgs"
FONT 8, "Arial"
BEGIN
CONTROL "Static",IDC_JPG,"Static",SS_BITMAP,10,10,480,380
END
Posted on 2002-06-11 09:14:46 by Olli
i posted one last week in another thread - try the search button, if you still dont find it - ask again, its somewhere on my hd
Posted on 2002-06-11 09:23:30 by Terab
I couldn't find it. I checked all the posts posted by "Terab" on this board but nothing on this topic.
Once again:
-I need to show the Image (test.jpg) in a static control
-Now i would like to resize it and put a text string onto it

Thanks in advance,
Olli
Posted on 2002-06-11 11:42:20 by Olli

I couldn't find it. I checked all the posts posted by "Terab" on this board but nothing on this topic.
Once again:
-I need to show the Image (test.jpg) in a static control
-Now i would like to resize it and put a text string onto it

Thanks in advance,
Olli


Perhaps you can find something usefull here:
http://www.programmersheaven.com/zone10/cat453/
Posted on 2002-06-11 12:00:12 by bazik
but i checked this out already. The library works fine it just doesn't show the jpg image on a static control. I tried a button control with BS_BITMAP style already but it still don't work.
Posted on 2002-06-11 12:13:43 by Olli