我用C++重现Photoshop的那次经历
That Time I Recreated Photoshop in C++

原始链接: https://f055.net/technology/that-time-i/that-time-i-recreated-photoshop-in-c/

2006年,出于对漫画的热爱以及对现有图片浏览器的失望,我用C++/Windows API编写了Fiew,一款鼠标控制的漫画阅读器。这次成功激发了我毕业论文项目的灵感:Fedit,一款类似Photoshop的高级图像编辑器。 Fedit采用C++和Windows API/GDI+开发,注重可移植性和最小资源占用。它包含浮动工具窗口、颜色拾取器、图层管理、可逆历史记录、图像滤镜和强大的图片库查看器。模拟Photoshop的工作流程是一个巨大的挑战,特别是吸附式UI元素。 尽管投入了大量时间并自学调试,我还是完成了Fedit并成功答辩。虽然Fedit获得了积极的反馈,但我并没有积极推广它。然而,这个项目给我带来了在GoldenLine从事C++开发工作的机会,负责开发高性能图像上传器,证明了之前的努力是值得的。Fedit和Fiew的源代码已上传至GitHub,毕业论文和原始网站可通过网络档案馆访问。

Hacker News 上的一个帖子讨论了一篇博客文章,该文章介绍了如何用 C++ 重建 Photoshop,重点是一个单一的、可移植的可执行文件。评论者们就这种方法与安装程序的优缺点进行了辩论,一些人赞扬了可移植软件的简洁性,另一些人则强调了安装程序在创建开始菜单快捷方式和文件关联方面的便利性。macOS 将文件关联信息嵌入可执行文件中的方法因其简洁性而受到称赞。 讨论还涉及到 Rust 的跨平台开发挑战、Windows 注册表的最初用途以及关于 GIMP 用户界面与 Photoshop 之间持续存在的争论。一些用户表达了对 AppData 文件夹的失望。一些评论者指出,像 Photopea 这样的免费替代品现在是很好的选择,但像这样的项目如果在 2006 年创建时作为商业产品,可能是可行的。文章还提到作者的项目没有进行推广,但最终帮助他找到了一份 C++ 的工作。

原文

As I’m getting older I look back on all the things I’ve done as a creative developer, and I see so many cool projects! But I never wrote down any development stories, and most of these projects, even as successful when released, got lost in time as years go by. That’s why I’m starting my new posts series „That time I” where I look back on my most interesting projects.

The first one is about that time I recreated Photoshop in C++ and Windows API! I invite you to read my story and leave a comment with feedback, it’s hard to go on without your input 🙂

Everything started in early summer of 2006. I was reading *a lot* of manga back then. But all the image reading apps sucked. Specifically, none of the apps allowed me to control my reading using just the mouse, and reaching my keyboard all the time was distracting. Since I just finished the C++/Windows API course at the uni, I spent the summer break coding my perfect manga reader. And I named it Fiew.

Early autumn 2006 we returned to uni and had to decide on our final thesis for the degree. Writing the image viewer went smooth enough that I got the idea I could create an image editor as well. I was a heavy Adobe Photoshop user back then, so that became my goal. I mean, how hard can it be? Turns out, very.

Over the course of the next several months, I wrote Advanced Image Editor named Fedit in C++ using Windows API and GDI+ graphic libraries. It followed a set of five rules to benefit the end user: no installers, no archives, no registry keys, no additional runtimes and a single executable file. The result was a program that was ready to work without the need of installation, could be run on systems with limited privileges (or straight from a thumb drive) and consumed small amounts of resources.

I was very careful to make the interface look like classic Photoshop, and include all my most used features. So you had all the free floating windows with tools. The excellent colour picker. Easy layer management. Step-by-step reversible history. Several image filters, plus a matrix interface to encode your own pixel shifting filters too.

Straight from my previous project named Fiew I added a massive image library viewer. It really could quickly and easily scroll through massive amounts of pictures.

I had a lot of fun coding Fedit. And a lot of issues along the way. I spent a ton of time on MSDN and Stack Overflow, however that didn’t help that much since most of the issues were so specific I had to analyse and debug them on my own. But I worked like crazy on it, my motivation was immense. I had to make the bachelor thesis deadline, so for the final two-month stint I worked 14 hours a day.

User interface was the most tricky bit. I wanted the workflow to resemble Photoshop as much as possible. The freely snapping-unsnapping of the tool settings pane was particularly hard. But no less than recreating the colour picker or the tool selector.

By the time I finished I was pretty exhausted and kind of resenting WinAPI. But the thesis was a success and I received my Bachelor of Science in Engineering from the Warsaw University of Technology. Fedit received several positive reviews online but I didn’t promote it. Instead I took a well deserved holiday. A few months later thanks to the impression Fiew and Fedit made on the CTO of GoldenLine (Polish LinkedIn, market leader in its time, but now defunct), I landed a C++ job with a task to create extremely efficient WinAPI app to handle massive image uploading for a clone of Flickr. So in the end all that effort paid off.

Fedit (and Fiew) source code is available on GitHub. The thesis documentation is available as PDF. The original website for these apps is still up on the Web Archive!

联系我们 contact @ memedata.com