topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Monday March 18, 2024, 10:41 pm
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: IDEA: Png Painter  (Read 8591 times)

Edvard

  • Coding Snacks Author
  • Charter Honorary Member
  • Joined in 2005
  • ***
  • Posts: 3,017
    • View Profile
    • Donate to Member
IDEA: Png Painter
« on: October 28, 2005, 12:44 PM »
Ok, let me explain. I am intending this for skinnable button images and etc. in Litestep and other skinnable thingummys, but it'd also work great for webpage graphics or graphic whatevers in general. The first problem is, I am on NT4 which can't handle png alpha channel natively, so I use an Autohotkey script to send a png and a background color to rpng.exe which paints a png on top of my intended background color with alpha-blend, Alt-PrintScreen to capture the window, and open in MSpaint or Ultimate Paint ('cause it handles png's and it's got a funky interface) to snip the graphic out and convert to png bmp or ico from there. Cumbersome to say the least.
Here's the Challenge: to shorten this process.
Sources and binaries for rpng are available at http://www.libpng.org/pub/png/book/sources.html
Hack the source or code your own which will do pretty much the same as rpng.exe But...
send output to file (png,bmp,jpg,etc.) or graphics editor (too many to list)
I've tried simply piping rpng.exe output to a file (rpng.exe > foo.bmp) but to no avail. rpng is intended only as an example thingamabob for coders and it appears they meant it.... Perhaps someone has an idea on how Autohotkey or some similar script prog can simply wait for the window to open and automagically cut out the contents of the window and save it rather than copying a picture of the entire window as Alt-PrintScreen does now.

skrommel

  • Fastest code in the west
  • Developer
  • Joined in 2005
  • ***
  • Posts: 933
    • View Profile
    • 1 Hour Software by skrommel
    • Donate to Member
Re: IDEA: Png Painter
« Reply #1 on: October 29, 2005, 12:51 PM »
 :) I think you can get this done using the command line options of

ImageMagik from http://www.imagemagick.org

or

Irfanview from http://www.irfanview.com/ with the png-plugin.

If not, it is possible to have AutoHotkey remove the border and titlebar of the rpng window using WinSet.

Skrommel

Edvard

  • Coding Snacks Author
  • Charter Honorary Member
  • Joined in 2005
  • ***
  • Posts: 3,017
    • View Profile
    • Donate to Member
Re: IDEA: Png Painter
« Reply #2 on: October 31, 2005, 11:30 AM »
I have not found imagemagick to be any kind of useful 'cause I never could get the darn thing to work. Exhaustive as the documentation is, I still could not get it to do exactly what I had hoped, but perhaps I should try again. As wonderful an app as IrfanView is, I cannot do what I hope from the simplicity of a command line. I will try the WinSet prog. Stay Tuned!

NoWhereMan

  • Participant
  • Joined in 2005
  • *
  • default avatar
  • Posts: 23
    • View Profile
    • Donate to Member
Re: IDEA: Png Painter
« Reply #3 on: October 31, 2005, 12:02 PM »
I'm sure with ImageMagick you can do what you need!  :Thmbsup:

Edvard

  • Coding Snacks Author
  • Charter Honorary Member
  • Joined in 2005
  • ***
  • Posts: 3,017
    • View Profile
    • Donate to Member
Re: IDEA: Png Painter
« Reply #4 on: November 01, 2005, 12:38 PM »
Ok, ImageMagick comes through, but in a way not entirely but almost, intuitively. First, I tried a batch file so I have an editable drop target that would make both pngs and bmp for testing:
(WARNING: the following will make most sense to those familiar with ImageMagick)
convert.exe %1 -background "rgb(213,204,187)" test.bmp test.png
Ok, the bmp turned out black on the proper background (not good) and the png looked good but there was something... I opened up the png in Ultimate Paint and there was my original png simply pasted on a background with alpha channel so it looked right, but it wasn't what I wanted. I wanted it mapped on the background so there was no alpha channel left, but the transitions to the background present. I tried all kinds of -channel operations and looked at the forums and in TFM stumbled on:
convert.exe %1 -background "rgb(213,204,187)" -FLATTEN test.bmp test.png
This is supposed to work on multiple images pasted on each other, so I thought I'd try it to 'flatten' my png on the background. TaDa. But the bmp was fuuunnnkkkyyy. Seems as though it was trying to write a 32-bit bmp when I can only deal with 24-bit or less. Tried -colors, -depth, nothing worked. Once again some rummaging around brought up:
convert.exe %1 -background "rgb(213,204,187)" -flatten +MATTE test.bmp test.png
apparently this had nothing to do with what I wanted to do, but it DID remove alpha channel information completely, so my bmp was properly 24-bit. Also, I discovered that the alpha channel HAD to be removed before the -colors option did anything. So now I have my batch code
convert.exe %1 -background "rgb(213,204,187)" -flatten +matte -colors 65536 test.bmp test.png
which can now be imported to a script where I can properly selectify my every whim. Thanks all for the encouragement to stick with IM and when I get a proper code worked up, I'll post it.