sz3905
asked on
Help converting MS "C" sample code
I've been trying to convert some C code with not much luck. The C code is a sample that fades a bitmap from black to color. After completely rewriting the sample in D3(3times), spending many days, hours, and many Evariant conversion errors, I realized I'm in over my head on this one. Does any one have converted D3 source of the following of fadein.c from microsoft. The source is at http://support.microsoft.com/support/kb/articles/q149/8/55.asp It's a self extracting exe
Much thanks in advance for even considering this conversion.
I dont want a compiled component because I want to take this code method/concept a lot further.
//Steve
//sbsullivan@ucdavis.edu
Much thanks in advance for even considering this conversion.
I dont want a compiled component because I want to take this code method/concept a lot further.
//Steve
//sbsullivan@ucdavis.edu
Woops, don't mention, it's a self-extracting file, sorry.
ASKER
Edited text of question
Hi,
Working on it too. How is yours going on Zif?
Igor
Working on it too. How is yours going on Zif?
Igor
Hi,
Working on it too. How it yours going on Zif?
Igor
Working on it too. How it yours going on Zif?
Igor
Hi inter,
Haven't done anything yet. My comment was of thursday evening. Then my server went down and now I haven't got time till this evening again. So, if yours is already done, please give it as an answer. But I'm going to try it out myself too. Maybe a new article is born here?
Regards, Zif.
Haven't done anything yet. My comment was of thursday evening. Then my server went down and now I haven't got time till this evening again. So, if yours is already done, please give it as an answer. But I'm going to try it out myself too. Maybe a new article is born here?
Regards, Zif.
I have translated the half of the code already. However there is a sort routine common to c++ named qsort(I should implement such thing in Delphi-or just cut and paste). Other than that, I think this question also helps us to answer the questions like How do I convert from 24 bit to 8 bit(as you can remember).
Regards,
Igor
Regards,
Igor
hi Inter,
Correct, the Quick Sort routine isn't standard implemented in Delphi. But that shouldn't be so hard.
Good luck.
Correct, the Quick Sort routine isn't standard implemented in Delphi. But that shouldn't be so hard.
Good luck.
Hi friends,
Now we have a translated source, BUT, just mangling the colors in the desktop!
Any comment?(I am trying to fix it)
Igor
Now we have a translated source, BUT, just mangling the colors in the desktop!
Any comment?(I am trying to fix it)
Igor
? Don't you've to assign a handler for changing the DIBbits? Now you probable take the handle of the desktop.
Ok THATS IT!
Do I paste the code here or send it?(Or who wants the source)
Igor
Do I paste the code here or send it?(Or who wants the source)
Igor
You may send me the code, if you want.
But also answer this question!!
Regards, Zif.
But also answer this question!!
Regards, Zif.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
My mailer still could not send the files. If you want I can paste it here. The raw code takes about 700 lines. But I may reduce it if I remove the comments from microsoft. What do you want. Also, are you there sz3905?
Igor
Igor
Inter, I received your mail 2 times. Many thanks already.
ASKER
Igor and Zif,
Yes i'm here.
I am truly impressed.
I just unzipped and am trying Igor's version(very good!) while it while we speak. . .
I'm not sure why I'm getting a incompatible types integer and pointer error in:
TheBitmap := CreateDIBSection(TheDC, pbmi^, DIB_RGB_COLORS, Pointer(pBits), nil, 0);
I shoudl know in a few minutes.
"What do you want."
I can wait for another email zip or raw email. What ever is convient for you guys.
Again, truly impressed
/steve
Yes i'm here.
I am truly impressed.
I just unzipped and am trying Igor's version(very good!) while it while we speak. . .
I'm not sure why I'm getting a incompatible types integer and pointer error in:
TheBitmap := CreateDIBSection(TheDC, pbmi^, DIB_RGB_COLORS, Pointer(pBits), nil, 0);
I shoudl know in a few minutes.
"What do you want."
I can wait for another email zip or raw email. What ever is convient for you guys.
Again, truly impressed
/steve
I am glad you receive it(by the way reject the answer if Zif also sends you the code, I want to share the points with him after the fix)
My delphi version is 2.0. So lets find the problem. First of all Do you have the source code for Delphi 3.0 components?(i.e. you have Client/Server or professional edition.) If so just open Windows.Pas from ..\source\rtl\win\ directory and search for CreateDIBSection( function. Comment it down here and we try to examine the incompatibility. My Windows.pas reports the following prototype:
function CreateDIBSection(DC: HDC; const p2: TBitmapInfo; p3: UINT;
var p4: Pointer; p5: PHandle; p6: DWORD): HBITMAP; stdcall;
Is it same?
(Also try add adding {$X+} after interface part please)
Igor
My delphi version is 2.0. So lets find the problem. First of all Do you have the source code for Delphi 3.0 components?(i.e. you have Client/Server or professional edition.) If so just open Windows.Pas from ..\source\rtl\win\ directory and search for CreateDIBSection( function. Comment it down here and we try to examine the incompatibility. My Windows.pas reports the following prototype:
function CreateDIBSection(DC: HDC; const p2: TBitmapInfo; p3: UINT;
var p4: Pointer; p5: PHandle; p6: DWORD): HBITMAP; stdcall;
Is it same?
(Also try add adding {$X+} after interface part please)
Igor
Hi there,
If you do not have the sources of VCL please indicate. By the way if you there Zif and have Delphi 3.0 please help (I wonder if I configure my compiler to prevent such errors from compiler options?)
Igor
If you do not have the sources of VCL please indicate. By the way if you there Zif and have Delphi 3.0 please help (I wonder if I configure my compiler to prevent such errors from compiler options?)
Igor
I think I have found. They probably fixed this in Delphi 3.0. so reports incompatible with 2.0. Please try the following variant of the code
CreateDIBSection(TheDC, pbmi^, DIB_RGB_COLORS, Pointer(pBits), 0, 0);
And please notify
Igor
CreateDIBSection(TheDC, pbmi^, DIB_RGB_COLORS, Pointer(pBits), 0, 0);
And please notify
Igor
ASKER
Will try
CreateDIBSection(TheDC, pbmi^, DIB_RGB_COLORS, Pointer(pBits), 0, 0);
asap and let you know
/Steve/sz3905
CreateDIBSection(TheDC, pbmi^, DIB_RGB_COLORS, Pointer(pBits), 0, 0);
asap and let you know
/Steve/sz3905
ASKER
removing "nil" helped
but . . .
AnimatePalette(hPal, 0, 256, @pe);
gives error imcompatible type "array" and "TPaletteEntry"
probably diff betweem D2 and D3 array pointers ?
/steve
but . . .
AnimatePalette(hPal, 0, 256, @pe);
gives error imcompatible type "array" and "TPaletteEntry"
probably diff betweem D2 and D3 array pointers ?
/steve
try
AnimatePalette(hPal, 0, 256, pe);
or
AnimatePalette(hPal, 0, 256, PPaletteEntry(@pe)^);
Igor
AnimatePalette(hPal, 0, 256, pe);
or
AnimatePalette(hPal, 0, 256, PPaletteEntry(@pe)^);
Igor
I should leave in a minute if you have a comment please present.
Igor
Igor
Sorry, was a way for a moment. Haven't D3, have D2. What's the problem at the moment?
I am back also,
No problem Zif, some of the API declarations of D2 and D3 varies like some pointers became Var etc. So, I am waiting to fix the things up from the errors reported to Steve by Delphi 3.0.
Igor(l.t. 8:49 p.m)
No problem Zif, some of the API declarations of D2 and D3 varies like some pointers became Var etc. So, I am waiting to fix the things up from the errors reported to Steve by Delphi 3.0.
Igor(l.t. 8:49 p.m)
ASKER
I was away also, but we're back
Okay just tried but no can compile. I'll spend more time using watches:
AnimatePalette(hPal, 0, 256, pe);=
gives error imcompatible type "array" and "PPaletteEntry"
AnimatePalette(hPal, 0, 256, PPaletteEntry(@pe)^); =
gives error imcompatible type "TPaletteEntry" and "PPaletteEntry" Note:this is where I had problems with my version
AnimatePalette(hPal, 0, 256, @pe);=
gives error imcompatible type "array" and "TPaletteEntry"
/steve/sz3905
Okay just tried but no can compile. I'll spend more time using watches:
AnimatePalette(hPal, 0, 256, pe);=
gives error imcompatible type "array" and "PPaletteEntry"
AnimatePalette(hPal, 0, 256, PPaletteEntry(@pe)^); =
gives error imcompatible type "TPaletteEntry" and "PPaletteEntry" Note:this is where I had problems with my version
AnimatePalette(hPal, 0, 256, @pe);=
gives error imcompatible type "array" and "TPaletteEntry"
/steve/sz3905
Then just this
AnimatePalette(hPal, 0, 256, PPaletteEntry(@pe));
Ok?
AnimatePalette(hPal, 0, 256, PPaletteEntry(@pe));
Ok?
Well, if you need some help (which I doubt), i'm still here (l.t. 20.00h)
Dear friend,
Please watch you mailbox so we clear the case tonight if you have time for it by now, or just respond to be off and we will deal it tomorow.
(If we do, would you please report all the API related errors in one or two comments so that we can fix it instant)
Regards,
Igor the watchdog timer(Just for fun friend)
Please watch you mailbox so we clear the case tonight if you have time for it by now, or just respond to be off and we will deal it tomorow.
(If we do, would you please report all the API related errors in one or two comments so that we can fix it instant)
Regards,
Igor the watchdog timer(Just for fun friend)
ASKER
Igor, Date: 11:09AM - March, 06, 1998 PST
I do not understand your last message? Please explain.
The source compiled but does not work.
/Steve
I do not understand your last message? Please explain.
The source compiled but does not work.
/Steve
Ok friend, forget about the last message, i just said "If you have time lets fix this thing"
Questions:
1 - Does your windows setup to 256 color?
2 - Can you see a bitmap when you press the button on the form?
3 - Can you see any color change in the desktop when you press the button?
4 - Does delphi display hints and if so what are they?
Sincerely,
Igor
ASKER
Igor,
It kinda works now.
1) It does now
2)Yes
3)Yes black to color with artifacts (desktop (everywhere)
4) No hints or warnings
/steve
It kinda works now.
1) It does now
2)Yes
3)Yes black to color with artifacts (desktop (everywhere)
4) No hints or warnings
/steve
Fine,
Since the palette animation uses DAC(a chip on video cards-or we used to do it with DAC) it may happen that the very high frequency pulses disturb your display. To prevent this, run your application full screen or if not, do this kind of animation with DirectX.
Do you have such a problem friend?
Igor
Since the palette animation uses DAC(a chip on video cards-or we used to do it with DAC) it may happen that the very high frequency pulses disturb your display. To prevent this, run your application full screen or if not, do this kind of animation with DirectX.
Do you have such a problem friend?
Igor
Dear friend,
(If you don't mind) what are you planning to do with these kind of animation?
Igor
(If you don't mind) what are you planning to do with these kind of animation?
Igor
ASKER
11:40AM - March, 06, 1998 PST
Igor,
No problem. U'm, I'm using a brand new HP Vectra.
Are you saying there is no way for a clean fade using
stock hardware and standard winapi calls?
If so, Is it that DirectX handles hardware differently?
You see, I'm from the old school and dont want
DirectX, ActiveX, ControlX, AlphaX, BetaX, or any other X driver
set of the week. I've always written driver-less software
Using only the existing OS. I write video software.
You did convert the code, thank You both!
So how do I split points between you and Zif?
/steve
Igor,
No problem. U'm, I'm using a brand new HP Vectra.
Are you saying there is no way for a clean fade using
stock hardware and standard winapi calls?
If so, Is it that DirectX handles hardware differently?
You see, I'm from the old school and dont want
DirectX, ActiveX, ControlX, AlphaX, BetaX, or any other X driver
set of the week. I've always written driver-less software
Using only the existing OS. I write video software.
You did convert the code, thank You both!
So how do I split points between you and Zif?
/steve
I am too friend,(from the old school, but just learn them for knowledge)
I just say few thing about video. You may probably know these, any way you may skip, sorry I just want to writedown.
The flickerless animation just use up 3 inline assembler lines in DOS days. As you may already know, the CRT traces every line and whole screen from left to right and top to bottom. The scan from left to right is called HScan(Horizontal) and from top to bottom called VScan. A 50Hz monitor scans whole the screen in every 20msecs. This setup time, between individual page scans is called Vertical Blank Period or shortly VBL. We may poll a grahic card register if it is in VBL. If we update the whole screen in that period there can be absolutely no flicker. So a simple function such as WaitVbl can prevent screen from flickering. Windows NT does not allow this(as you now is is !SECURE!) But win95 may? I can not remember the port number and mask but if you want find them. If it works on win95, your animations may works flicker free regardless of the complexity of your scene.
Thanks, have a nice day(we have a nice night here too)
and Regards
Igor
I just say few thing about video. You may probably know these, any way you may skip, sorry I just want to writedown.
The flickerless animation just use up 3 inline assembler lines in DOS days. As you may already know, the CRT traces every line and whole screen from left to right and top to bottom. The scan from left to right is called HScan(Horizontal) and from top to bottom called VScan. A 50Hz monitor scans whole the screen in every 20msecs. This setup time, between individual page scans is called Vertical Blank Period or shortly VBL. We may poll a grahic card register if it is in VBL. If we update the whole screen in that period there can be absolutely no flicker. So a simple function such as WaitVbl can prevent screen from flickering. Windows NT does not allow this(as you now is is !SECURE!) But win95 may? I can not remember the port number and mask but if you want find them. If it works on win95, your animations may works flicker free regardless of the complexity of your scene.
Thanks, have a nice day(we have a nice night here too)
and Regards
Igor
ASKER
It's a nice welcome to hear same beliefs as I have. W95 is very forgiving and implemeting
a write on vertical retrace is a snap while in Nt4.0 it is forbidden. I'll work with your solution. I can still use the code with slight mods. I'm going to try to split or give points by asking another fake question for Zif (reopen) after I close this question.
Again, I am impressed.
Best Regard,
Steve Sullivan
a write on vertical retrace is a snap while in Nt4.0 it is forbidden. I'll work with your solution. I can still use the code with slight mods. I'm going to try to split or give points by asking another fake question for Zif (reopen) after I close this question.
Again, I am impressed.
Best Regard,
Steve Sullivan
I went to that page, but can't find any source except for the program, namely FADEIN.EXE
Regards, Zif