Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

JanGraphics.dll - how to use

205 views
Skip to first unread message

Franz Bachler

unread,
Nov 12, 2009, 5:43:00 AM11/12/09
to
Hello,

I would like to convert a gif-File into a bmp- or jpg-File with
janGraphics.dll.

Input for example "image.gif" - output "image.bmp".

There must be a function called "convert". But the dll is a COM or COM+ dll
so I don't what should I do.

EXPORTS
DllCanUnloadNow @3 ; DllCanUnloadNow
DllGetClassObject @4 ; DllGetClassObject
DllRegisterServer @2 ; DllRegisterServer
DllUnregisterServer @1 ; DllUnregisterServer

Greetings,
Franz

--
Franz Bachler
A-3250 Wieselburg
E-Mail: fraba (at) gmx.at
Homepage: http://members.aon.at/fraba
or http://home.pages.at/fraba


Dee Earley

unread,
Nov 12, 2009, 6:20:10 AM11/12/09
to
On 12/11/2009 10:43, Franz Bachler wrote:
> Hello,
>
> I would like to convert a gif-File into a bmp- or jpg-File with
> janGraphics.dll.
>
> Input for example "image.gif" - output "image.bmp".
>
> There must be a function called "convert". But the dll is a COM or COM+ dll
> so I don't what should I do.
>
> EXPORTS
> DllCanUnloadNow @3 ; DllCanUnloadNow
> DllGetClassObject @4 ; DllGetClassObject
> DllRegisterServer @2 ; DllRegisterServer
> DllUnregisterServer @1 ; DllUnregisterServer

It's a COM DLL so you can't use normal imports.
You'll need to check with the author of the library for an SDK, and with
the documentation for whatever language/IDE you use on how you
instantiate COM objects.

--
Dee Earley (dee.e...@icode.co.uk)
i-Catcher Development Team

iCode Systems

Christian ASTOR

unread,
Nov 12, 2009, 7:27:26 AM11/12/09
to
On 12 nov, 11:43, "Franz Bachler" <fraba.nos...@gmx.at> wrote:

> I would like to convert a gif-File into a bmp- or jpg-File with
> janGraphics.dll.

Use GDI+ instead.
(or SHConvertGraphicsFile())

Franz Bachler

unread,
Nov 12, 2009, 2:03:21 PM11/12/09
to
>> I would like to convert a gif-File into a bmp- or jpg-File with
>> janGraphics.dll.
> (or SHConvertGraphicsFile())

http://www.tech-archive.net/Archive/Development/microsoft.public.win32.programmer.ui/2006-12/msg00150.html

(FARPROC&)pSHConvertGraphicsFile = GetProcAddress(hInstance,
MAKEINTRESOURCE(488));

(FARPROC&) must be replaced with (FARPROC)
okay, was a typing error

But I would like replace

pSHConvertGraphicsFile(L"_kk_xy_.gif",L"_kk_xy_.bmp", 1);

with

TCHAR szGifTemp[MAX_PATH];
TCHAR szBmpTemp[MAX_PATH];

GetTempPath(sizeof(szGifTemp), szGifTemp);
GetTempPath(sizeof(szBmpTemp), szBmpTemp);
strcpy(szGifTemp, TEXT("_kk_xy_.gif"));
strcpy(szBmpTemp, TEXT("_kk_xy_.bmp"));

// that's the problem line
pSHConvertGraphicsFile(szGifTemp, szBmpTemp, 1);

Thanks for helping!

The reason for this conversation is because OpenCV can't display GIF-Image
and so GIFs are converted into BMP before opened with OpenCV.

Greetings,
Franz


Christian ASTOR

unread,
Nov 12, 2009, 4:40:05 PM11/12/09
to
On 12 nov, 20:03, "Franz Bachler" <fraba.nos...@gmx.at> wrote:

> (FARPROC&) must be replaced with (FARPROC)
> okay, was a typing error

No, it's really (FARPROC&)

>       GetTempPath(sizeof(szGifTemp), szGifTemp);
>       GetTempPath(sizeof(szBmpTemp), szBmpTemp);
>       strcpy(szGifTemp, TEXT("_kk_xy_.gif"));
>       strcpy(szBmpTemp, TEXT("_kk_xy_.bmp"));

This code is not correct.
You can do :
GetTempPath(MAX_PATH, szGifTemp);
GetTempPath(MAX_PATH, szBmpTemp);
lstrcat(szGifTemp, TEXT("_kk_xy_.gif"));
lstrcat(szBmpTemp, TEXT("_kk_xy_.bmp"));

Franz Bachler

unread,
Nov 15, 2009, 11:08:03 PM11/15/09
to
>> I would like to convert a gif-File into a bmp- or jpg-File with
>> janGraphics.dll.
> Use GDI+ instead.
> (or SHConvertGraphicsFile())

Please an Example with GDI+:

- load the grafic file "name.gif" or "name.jpg"
- open a window
- show the grafic in the window

SHConvertGraphicsFile() works only with WinXP & Vista but no more with
Seven. But it's possible to copy "shlwapi.dll" from WinXP to the directory
of the application, rename it and open the renamed DLL instead. Under
Win2000 you can forget this method.

Greetings,
Franz


Christian ASTOR

unread,
Nov 16, 2009, 6:46:12 AM11/16/09
to
On 16 nov, 05:08, "Franz Bachler" <fraba.nos...@gmx.at> wrote:

> Please an Example with GDI+:
> - load the grafic file "name.gif" or "name.jpg"
> - open a window
> - show the grafic in the window

See MSDN :
http://msdn.microsoft.com/en-us/library/ms533830(VS.85).aspx

Franz Bachler

unread,
Nov 16, 2009, 10:40:34 AM11/16/09
to
> See MSDN :
> http://msdn.microsoft.com/en-us/library/ms533830(VS.85).aspx

Cool Example, it works; but I would like also to zoom the graphic with the
window and not only have a fixed size

VOID OnPaint(HWND hWnd)

{
HDC hdc;
PAINTSTRUCT ps;
hdc = BeginPaint(hWnd, &ps);
Graphics graphics(hdc);
GetImagefromWeb();
Image image(L"name.jpg");
graphics.DrawImage(&image, 0, 0);
EndPaint(hWnd, &ps);
}

Greetings,
Franz


Christian ASTOR

unread,
Nov 16, 2009, 12:13:39 PM11/16/09
to
On 16 nov, 16:40, "Franz Bachler" <fraba.nos...@gmx.at> wrote:
> > See MSDN :
> >http://msdn.microsoft.com/en-us/library/ms533830(VS.85).aspx
>
> Cool Example, it works; but I would like also to zoom the graphic with the
> window and not only have a fixed size

If you want to resize it, just get the coordinates of client area =>

RECT rc;
GetClientRect(hWnd, &rc);
Graphics graphics(hdc);
Image image(L"test.jpg");
graphics.DrawImage(&image, 0, 0, rc.right-rc.left, rc.bottom-rc.top);

Franz Bachler

unread,
Nov 16, 2009, 2:35:34 PM11/16/09
to
>> > See MSDN :
>> >http://msdn.microsoft.com/en-us/library/ms533830(VS.85).aspx
>> Cool Example, it works; but I would like also to zoom the graphic with
>> the
>> window and not only have a fixed size
> If you want to resize it, just get the coordinates of client area =>
> RECT rc;
> GetClientRect(hWnd, &rc);
> Graphics graphics(hdc);
> Image image(L"test.jpg");
> graphics.DrawImage(&image, 0, 0, rc.right-rc.left, rc.bottom-rc.top);

Yes, thanks that works fine and I was successful to combine it with my
approved flicker-free code.


Friedel Jantzen

unread,
Nov 17, 2009, 2:31:19 AM11/17/09
to
Am Mon, 16 Nov 2009 16:40:34 +0100 schrieb Franz Bachler:
>...

> VOID OnPaint(HWND hWnd)
>
> {
> HDC hdc;
> PAINTSTRUCT ps;
> hdc = BeginPaint(hWnd, &ps);
> Graphics graphics(hdc);
> GetImagefromWeb();
> Image image(L"name.jpg");
> graphics.DrawImage(&image, 0, 0);
> EndPaint(hWnd, &ps);
> }
>

A members table of Image is here:
http://msdn.microsoft.com/en-us/library/ms534462(VS.85).aspx

You may consider to preload Image before WM_PAINT, so that it
is not reloaded every time OnPaint is called, e.g. in OnCreate
using Image::FromFile.

Regards,
Friedel

Franz Bachler

unread,
Nov 17, 2009, 12:01:15 PM11/17/09
to
>> VOID OnPaint(HWND hWnd)

>> {
>> HDC hdc;
>> PAINTSTRUCT ps;
>> hdc = BeginPaint(hWnd, &ps);
>> Graphics graphics(hdc);
>> GetImagefromWeb();
>> Image image(L"name.jpg");

>> graphics.DrawImage(&image, 0, 0, rc.right-rc.left, rc.bottom-rc.top);


>> EndPaint(hWnd, &ps);
>> }
> A members table of Image is here:
> http://msdn.microsoft.com/en-us/library/ms534462(VS.85).aspx
> You may consider to preload Image before WM_PAINT, so that it
> is not reloaded every time OnPaint is called, e.g. in OnCreate
> using Image::FromFile.

Please can you give me an example how to change my above code for use with
Image::FromFile. Thanks


Friedel Jantzen

unread,
Nov 18, 2009, 3:02:34 AM11/18/09
to

Image::FromFile:
http://msdn.microsoft.com/en-us/library/ms535370(VS.85).aspx

// a sample:
// assuming Gdiplus namespace is set
Image *image = NULL;

Image* LoadMyImage(WCHAR *imgPath)
{
GetImagefromWeb(); // ?, from your code

Image *img = Image::FromFile(imgPath, FALSE);
if(img->GetLastStatus() == Ok) return img;
if(img) delete img;
return NULL;
}

// can load the image on WM_CREATE or after CreateWindow returns, before
ShowWindow.
void OnCreate(.....)
{
// .....
image = LoadMyImage(L"name.jpg");
if(image == NULL) // .... error message

// .....
}

void OnDestroy(.....)
{
// .....
delete image; image = NULL;
}

VOID OnPaint(HWND hWnd)
{
HDC hdc;
PAINTSTRUCT ps;
hdc = BeginPaint(hWnd, &ps);
Graphics graphics(hdc);

// Declare and define rc here, if the image must fit into rc (user can
resize window)!
RECT rc;
GetClientRect(hWnd, &rc); // -> rc.left and rc.top are always 0.
// With this code the image will be distorted, if image->GetWidth/GetHeight
// is different from window's rc width/height, ok?
if(image != NULL) graphics.DrawImage(image, 0, 0, rc.right, rc.bottom);
EndPaint(hWnd, &ps);
}

hth,
Friedel

Franz Bachler

unread,
Nov 18, 2009, 10:28:06 AM11/18/09
to
> hth,
> Friedel

Hey Friedel, super Code!!!
I've only experience with "normal" C.
If you would like you can contact me directly - in German language *g*
or you'll find the program in a few days or weeks on my download page:

http://members.aon.at/fraba/download.htm

Greetings,
Franz

Friedel Jantzen

unread,
Nov 19, 2009, 3:22:23 AM11/19/09
to
Am Wed, 18 Nov 2009 16:28:06 +0100 schrieb Franz Bachler:

>> hth,
>> Friedel
>
> Hey Friedel, super Code!!!

It's not tested, just written down :-)

> I've only experience with "normal" C.

Learning C++ is not difficult, if your C knowledge is good.
Not quite easy is the use of advanced features and design patterns.
Google for "C++ tutorial", you'll find a lot of introductions.
And perhaps a public library is near.
IMO it is worthwhile. Better design, easier maintainance, reusable code ...

> If you would like you can contact me directly - in German language *g*

Yes, for lengthy posts this will be good.
But your questions and the answers may be interesting for others, too.
Some questions come up repeatedly here, e.g. how to draw images using GDI+.

I hope, my oldie school English will be understood, at least partly :-)

> or you'll find the program in a few days or weeks on my download page:
> http://members.aon.at/fraba/download.htm

Do not hurry, test it thoroughly before publishing.

BTW: You still have a MSX running?

> Greetings,
> Franz

Regards,
Friedel

Franz Bachler

unread,
Nov 20, 2009, 2:43:06 AM11/20/09
to
"Friedel Jantzen" <nospa...@freenet.de> wrote in message
news:1p09465lnebh2$.13ecq74rflw17$.dlg@40tude.net...

> Am Wed, 18 Nov 2009 16:28:06 +0100 schrieb Franz Bachler:
>> Hey Friedel, super Code!!!
> It's not tested, just written down :-)

That made I for you *g*

>> I've only experience with "normal" C.
> Learning C++ is not difficult, if your C knowledge is good.

step by step ...

> I hope, my oldie school English will be understood, at least partly :-)

me too and a good opportunity not for unlearn *g*

> BTW: You still have a MSX running?

no really, but I use sometimes RuMSX-Emulator. From all me MSX-disks I've
made an image (self written MS-DOS-Programm of course in C). Three
MSX-Computers are in a cupboard; last turned on in 2004. But one key hanged.
So I've cleaned the film under the keys with isopropyl alcohol and all
worked. But I'm a little bit worry about the electrolytic capacitors over
the years.

I've a Pentium III Mainboard from MSI bought 2002 and it worked over 5 years
and then the system always frozen during the boot process. Approx. one year
it was okay to let it 15 min turned on and it worked for several hours
without frozen.But then it frozen every 10 - 15 min. I've googled that in
2002 there were built in series with wrong type of electrolyt inside. Now
the board is removed but the condensators had no leaking electrolyt.

Greetings,
Franz


Franz Bachler

unread,
Nov 20, 2009, 2:55:34 AM11/20/09
to
Hello again,

okay now the program works as a matter in principle. But

- the picture image e.g. from a webcam is downloaded to an array of char
- than the array is written to a file
- than this file is load with Image::FromFile

Here's the "heart" of the code for reading the image from web to the array
"szData" with size "dwSize":

InternetReadFile(hIF, (LPVOID) szData, iBufferSize-10, &dwSize);
if (dwSize!=0) szData[dwSize]='\0';

How must this code be replaced for direct writing the content of the array
to the screen without puffering in a file?

RECT rc;
GetClientRect(hWnd, &rc);
Graphics graphics(hdc);

Image image(L"test.jpg");


graphics.DrawImage(&image, 0, 0, rc.right-rc.left, rc.bottom-rc.top);

If it necessary, my code knows if a picture is a BMP,GIF,PNG or JPG.

Greetings,
Franz


Friedel Jantzen

unread,
Nov 20, 2009, 4:20:15 AM11/20/09
to
Hi Franz,

Am Fri, 20 Nov 2009 08:55:34 +0100 schrieb Franz Bachler:
> ...

> How must this code be replaced for direct writing the content of the array
> to the screen without puffering in a file?

In the code I posted, you can replace Image::FromFile with
Image::FromStream, after you created the stream using
CreateStreamOnHGlobal:

something like:

// data is in fPtr, size = fSize
IStream *stream = 0;
// write image data to stream
if(CreateStreamOnHGlobal(NULL, TRUE, &stream) != S_OK) {
DisplayOutOfMemory();
return;
}
ULONG nWritten;
LARGE_INTEGER dMove = {0};
stream->Write(fPtr, fSize, &nWritten);
stream->Seek(dMove, STREAM_SEEK_SET, NULL);

// create image from stream
image = Gdiplus::Image::FromStream(stream);
if(stream) stream->Release();

Gdiplus::Status stat = image->GetLastStatus();
if(stat == Gdiplus::Ok) {
// do it
}
else // Error message, cleanup

hth,
Friedel

Friedel Jantzen

unread,
Nov 20, 2009, 4:41:55 AM11/20/09
to
Hi Franz,

>>> I've only experience with "normal" C.
>> Learning C++ is not difficult, if your C knowledge is good.
>
> step by step ...

IMO it is good, that C++ does not force you to use all features, you can
mix it with C and start with a few classes in your application.

>> BTW: You still have a MSX running?
>
> no really, but I use sometimes RuMSX-Emulator. From all me MSX-disks I've
> made an image (self written MS-DOS-Programm of course in C). Three
> MSX-Computers are in a cupboard; last turned on in 2004. But one key hanged.
> So I've cleaned the film under the keys with isopropyl alcohol and all
> worked.

Good idea.

A friend of mine bought a MSX, and had to go to work in India then.
So I had a MSX for a year or so. Borland sold a MSX version of Turbo Pascal
3.

> But I'm a little bit worry about the electrolytic capacitors over
> the years.
>
> I've a Pentium III Mainboard from MSI bought 2002 and it worked over 5 years
> and then the system always frozen during the boot process. Approx. one year
> it was okay to let it 15 min turned on and it worked for several hours
> without frozen.But then it frozen every 10 - 15 min. I've googled that in
> 2002 there were built in series with wrong type of electrolyt inside. Now
> the board is removed but the condensators had no leaking electrolyt.

Afaik the problem is not only leaking, but they lose capacity if unused.
To prevent this, electronic devices should be turned on every few months
for an hour or so. It is good for the motors of HD etc., too.

Thank you for your reply,
Friedel

Franz Bachler

unread,
Nov 20, 2009, 5:54:58 AM11/20/09
to
> // data is in fPtr, size = fSize
> IStream *stream = 0;

Cool it really works! Only this must be replaced with:

IStream* stream = NULL;

Friedel this could be the begin of a E-Mail-friendship if you contact me.
But don't worry, I know all about whats necessary at the moment and will not
start more projects.

Greetings,
Franz


Friedel Jantzen

unread,
Nov 21, 2009, 3:12:09 AM11/21/09
to
Hi Franz,

Am Fri, 20 Nov 2009 11:54:58 +0100 schrieb Franz Bachler:

>> // data is in fPtr, size = fSize
>> IStream *stream = 0;
>
> Cool it really works! Only this must be replaced with:
>
> IStream* stream = NULL;

I forgot to say, that of course it is not necessary to write the data to
the stream, if it is already in a GlobalAlloc'ed memory block, which you
pass to CreateStreamFromHGlobal:
http://msdn.microsoft.com/en-us/library/aa378980(VS.85).aspx

DWORD size = ....
HGLOBAL hMem = GlobalAlloc(GHND, size); // moveable and nondiscardable
if(hMem == NULL) ..... Error
LPVOID szData = GlobalLock(hMem);
// now use this buffer to read your data into:
InternetReadFile(hIF, szData, iBufferSize-10, &dwSize);
// ...
GlobalUnlock(hMem);
if(CreateStreamOnHGlobal(hMem, TRUE, &stream) == S_OK) {


// create image from stream
image = Gdiplus::Image::FromStream(stream);

....

> Friedel this could be the begin of a E-Mail-friendship if you contact me.

I'll mail you to the mail address 1 on your homepage.

> But don't worry, I know all about whats necessary at the moment and will not
> start more projects.

:-) Why not?

> Greetings,
> Franz

Regards,
Friedel

0 new messages