EEVblog Electronics Community Forum

Electronics => PCB/EDA/CAD => Eagle => Topic started by: l3VGV on November 15, 2016, 12:29:09 am

Title: Eagle negative printing
Post by: l3VGV on November 15, 2016, 12:29:09 am
So i made some hobby project in eagle only to find out that in 2016 i cannot print it in negative(for photoresist dry film). Well i do not have Adobe Post script editor, or gerber viewer.  But i have more than 20years of windows programming experience...

How hard can it be to modify a program without source code for some feature that exist in all other similar apps. Well, its pretty simple - microsoft did everething to make it so.

I made a Detours dll wich hack inside eagle process and get things right.
How to use it,
1) we need withdll.exe its a part of microsoft detours (express version is free and limited to x86 u can get it there https://www.microsoft.com/en-us/research/project/detours/ (https://www.microsoft.com/en-us/research/project/detours/) )
2) eaglecad_helper.dll with all the magic
3) we need to use withdll.exe to load that dll into eagle process. i doing that with shortcut like that
withdll.exe -d:eaglecad_helper.dll "e:\elec\EAGLE-7.2.0\bin\eagle2.exe"

where bold part is path to your eagle executable.

withdll.exe will run a new copy of eagle with dll injected and then if u print somethin it will come out in negative colors. If u need normal printing just restart eagle normaly.


Work good on my laser jet 1018 and canon ink printer mg5340, and some other. Should work with any eagle version but only 32bit build.



**********



Here is source code, so complicated that thay can not do it without my help:

Code: [Select]
__declspec(dllexport) int WINAPI  MyEndPage(__in HDC hdc)
{
printInAction = 0;


PatBlt ( hdc, 0, 0, GetDeviceCaps ( hdc, HORZRES ), GetDeviceCaps ( hdc, VERTRES ), DSTINVERT );


return TrueEndPage(hdc);
}


BOOL APIENTRY DllMain( HMODULE hModule,
                       DWORD  ul_reason_for_call,
                       LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}



if (ul_reason_for_call == DLL_PROCESS_ATTACH)
{
DetourRestoreAfterWith();
DetourTransactionBegin();
DetourUpdateThread(GetCurrentThread());
DetourAttach(&(PVOID&)TrueEndPage, MyEndPage);
DetourTransactionCommit();
}
else if (ul_reason_for_call == DLL_PROCESS_DETACH)
{
DetourTransactionBegin();
DetourUpdateThread(GetCurrentThread());
DetourDetach(&(PVOID&)TrueEndPage, MyEndPage);
DetourTransactionCommit();
}


return TRUE;
}

PatBlt ( hdc, 0, 0, GetDeviceCaps ( hdc, HORZRES ), GetDeviceCaps ( hdc, VERTRES ), DSTINVERT );
that part is doing actual work, 1 line of code. everething else is just detour hack sturtup code...


I attached compiled version and sources, u can build it with visual studio express.
Title: Re: Eagle negative printing
Post by: jgarc063 on November 15, 2016, 04:57:57 pm
Wow I3VGV,

That is very impressive. I just wanted to let you know that in the CAM processor you can use the PS_INVERTED device in order to get inverted postscript for generating your negatives.

I enjoyed reading about how you did the hack, I'm sure others will find it useful for other applications.

Best Regards,
Jorge Garcia
Autodesk Support
Title: Re: Eagle negative printing
Post by: l3VGV on November 16, 2016, 10:21:36 am
What one do with postscript files nowdays? Is there any good and free software to view and print it? I wasnt able to find any.
Title: Eagle negative printing
Post by: timb on November 16, 2016, 12:32:19 pm
What one do with postscript files nowdays? Is there any good and free software to view and print it? I wasnt able to find any.

GSView/Ghostscript for viewing/printing, etc.

And yes, PostScript is still widely used today. You may even use it on a daily basis and not even know it! The entire macOS/iOS display subsystem (Quartz) is based on PostScript. PDF is also based on PostScript.

Fun Fact: PostScript is actually a (Turing complete) programming language.
Title: Re: Eagle negative printing
Post by: technotronix on December 30, 2016, 07:52:31 am
Thanks for sharing your eagle project here. I really enjoyed.
Title: Re: Eagle negative printing
Post by: richardlawson1489 on February 01, 2017, 07:43:33 am
What one do with postscript files nowdays? Is there any good and free software to view and print it? I wasnt able to find any.

Learn more on postscript from here. http://www.howtogeek.com/100016/printing-what-is-postscript/ (http://www.howtogeek.com/100016/printing-what-is-postscript/)