Pikona - Puppy Icon Assembler NEW and TINY! - v.0.4e

Window managers, icon programs, widgets, etc.
Message
Author
User avatar
vovchik
Posts: 1507
Joined: Tue 24 Oct 2006, 00:02
Location: Ukraine

future pikona mod

#21 Post by vovchik »

Dear Barry,

I have thought of several things in order to remove the IM dependencies. MU once posted three little utilities he wrote in c (each of which is about 4k compiled) that would do the job, except that one of them - scale2png - screws up when it comes to the alpha channel at high bit depth. The code is tiny, so I should look at it and try to do a rewrite in BaCon or use the modded c code directly (BaCon allows for that as a USEC). I would just have to get the IMPORT stuff straightened out, since these CLI progs make use of GTK (mainly gdk_pixbuf). I have already written a tiny bit of test code that is CLI but uses the GTK libs, so I think I can manage. What I would really like is totally self-contained code - apart from shared libs that are available on each and every Puppy (X11, GDK, GTK). I will look at netpbm, too. Ideally, the graphic transformations should all take place within Pikona (in RAM). It would make the program much faster and prevent dependency hell.

I have attached Mark's source for the utilities that could, with a bit of reworking, replace IM. They were part of his Scale2pics package and have nice potential.

With kind regards,
vovchik
Attachments
source.tar.gz
(5.44 KiB) Downloaded 798 times

big_bass
Posts: 1740
Joined: Mon 13 Aug 2007, 12:21

#22 Post by big_bass »

Hey vovchik
thanks for posting the source .There is one more needed scale2png.c

that wasnt in the source there was only the bin .Here it is the "make" is the same



I'll post it here
Joe
MU once posted three little utilities he wrote in c (each of which is about 4k compiled) that would do the job, except that one of them - scale2png - screws up when it comes to the alpha channel at high bit depth.



char *quality = "75"; what would happen if that was 100 ?


unedited original source
call it scale2png.c



Code: Select all

#include <gdk/gdkx.h>
#include <gdk-pixbuf/gdk-pixbuf.h>

GdkPixbuf *im , *im2;


int main(int argc, char **argv) {

 gdk_init(&argc,&argv);

  char *thefile;
  char *outfile;
  char *theheight = "20";
  char *thewidth = "20";
  char *quality = "75";

  

  if ( argc == 1 ){
 	return 1;
  }
 

  thefile = argv[1];
  outfile = argv[2];
  thewidth = argv[3];
  theheight = argv[4];
  quality = argv[5];

  float theight = atoi(theheight);
  float twidth = atoi(thewidth);

  char newquality[1024];
  float q=atoi(quality);
  float newq=100-q;

  int q2=newq/10;
  sprintf(newquality ,"%d" , q2);
 //printf("quality: %s\n" ,newquality);

  char roxpic[1024];
  sprintf(roxpic , "%s" , outfile);

// printf("option: %s\n" ,option);
 

  char jpgname[1024];

  sprintf(jpgname,roxpic);
  int zoom_quality = (int)GDK_INTERP_HYPER;

  im2 = gdk_pixbuf_new_from_file ( thefile , NULL);


float w=0;
float h=0;
float rx=0;
float ry=0;
int neww;
int newh;
int newx=0;
int newy=0;

  w=gdk_pixbuf_get_width(im2);
  h=gdk_pixbuf_get_height(im2);

  rx=twidth / w;
  ry=theight / h;


if(theight==twidth){
	  neww=twidth;
	  newh=theight;
}else{
	if(rx <=ry){
	  neww=twidth;
	  newh=h*rx+1;
	  //newy=(theight/2)-(newh/2);
	}else{
	  neww=w*ry+1;
	  newh=theight;
	  //newx=(twidth/2)-(neww/2);
	}
}



  im = gdk_pixbuf_scale_simple(im2, neww , newh, (GdkInterpType)zoom_quality);

  gdk_pixbuf_save ( im , jpgname , "png" ,NULL, "compression" , newquality, NULL);


  gdk_pixbuf_unref(im);
  gdk_pixbuf_unref(im2);	

//gdk_flush();

printf("%d\n%d\n", neww , newh);

  return 0;

}


User avatar
vovchik
Posts: 1507
Joined: Tue 24 Oct 2006, 00:02
Location: Ukraine

good news - bad news

#23 Post by vovchik »

Dear Joe,

The intermediate news is that I am almost finished porting scale2png.


The good news is that:

Code: Select all

quality = "100"
q = VAL(quality$)
newq = 100 - q
q2 = newq / 10
PRINT q2
does not generate a "division by zero" error. :)

The bad news is that it generates a value of "0". :(

But the prog does not stop and keeps going.

With kind regards,
vovchik

big_bass
Posts: 1740
Joined: Mon 13 Aug 2007, 12:21

#24 Post by big_bass »

if we had some real values to substitute "print out" to verify that all reduces down to a very simple math equation :idea:

------------------------------------------------------

aaphoto is a pre compiled bin but guess what here is the source :D

--png *PNG image output with alpha channel support

http://aaphoto.sourcearchive.com/docume ... files.html
http://aaphoto.sourcearchive.com/docume ... ource.html

User avatar
vovchik
Posts: 1507
Joined: Tue 24 Oct 2006, 00:02
Location: Ukraine

Picscale 0.1a - updated

#25 Post by vovchik »

Dear Puppians,

With the kind assistance of Peter (www.basic-converter.org), I got a first"draft" of picscale working in BaCon. If anybody has suggestions on how to improve the quality of the jpg conversion, please let me know. A binary and source are in the archive.

With kind regards,

PS. I think I am moving towards an ImageMagick-free Pikona. All I now need to do is to figure out how to use gdk_pixbuf to overlay images. Dammit, it looks like I will, at long last, have to consult the documentation. :)

UPDATE: I updated the archive since I fixed the bad jpg rendering and cleaned up the code a little bit.

UPDATE2: In fixing the jpeg quality stuff, I managed to destroy png transparency. It is now fixed and the archive has been updated. Sorry about that. :(
Attachments
picscale.tar.gz
(14.87 KiB) Downloaded 1480 times

big_bass
Posts: 1740
Joined: Mon 13 Aug 2007, 12:21

#26 Post by big_bass »

Hey vovchik

That was fast converting all that c code into BaCon!!

I am trying to follow what you did so I can figure out whats going on between c code and Bacon coding

these are some notes and questions I have

since this is a major move ahead to port to BaCon a heavily commented
first draft version is very welcomed


1.) the original code scale2png.c was small but not well commented at all so an abstract math equation for me because of not having a known value for w and h and other values

which makes the logical part of the rx and ry obscure

*I like how you made the variables clearer to read



I dont understand the less than or equal to in the ELSE
IF r_x<=r_y

I would hope for a check for less than --- then a condition
or an equal to --- then a condition
for debugging to see what value you get

I like how you did this part could you add (for debugging verbose )

---------------------------------------------------

' -----------
SUB REPORT_RESULTS()
' -----------
IF FILEEXISTS(new_file$) THEN
PRINT "File ", new_file$, " created."
PRINT "Original image: ", org_file$
PRINT "New dimensions (w x h): ", new_width$, " x ", new_height$
PRINT "Quality of new image: ", quality$
PRINT "Verbose debugging info below "
PRINT "r_x =:",r_x$
PRINT "r_y =:",r_y$
PRINT "h =:",h$
PRINT "y =:",y$
PRINT "q =:",q$
PRINT "q2 =:",q2$
PRINT "new_quality =:",new-quality$
PRINT "new_q =:",new_q$
PRINT "t_height =:",t_height$
PRINT "t_width =:",t_width$



ELSE
PRINT "OOPS.. something terrible happened and ", new_file$, " was not created."
END IF
gtk_exit(0)
END SUB
---------------------------------------------------

3.) the IMPORTS need to be explained well commented how that was done


4.) what is very interesting is how the c part
of the code changes very little in the conversion except for the complex import part :D

thanks for all your work on this I will learn a lot from it

*maybe another simple c code example with imports( for one trying to learn)
then ported to BaCon

Joe

big_bass
Posts: 1740
Joined: Mon 13 Aug 2007, 12:21

#27 Post by big_bass »

two small scripts to get started with BaCon


Code: Select all


#!/bin/bash


# Joe Arose  big_bass 11-14-2010
# call the auto-build-compile-bacon
# auto download compile install  and test Bacon and the 18 basic examples
# so you can easily update when needed


Xdialog --wrap --title "bacon instlaller" \
        --yesno "Do you want to install bacon  " 0 0

case $? in
  0)
    echo "Yes chosen."
   


rm -f  bacon.bash*
rm -f  bacon.bac*
rm -f  bacon

xterm  -geometry 40x30+150+40 -e wget http://www.basic-converter.org/bacon.bash
chmod a+x bacon.bash


xterm  -geometry 40x30+150+40 -e wget http://www.basic-converter.org/bacon.bac
chmod a+x bacon.bac


xterm  -geometry 40x30+150+40 -e ./bacon.bash bacon.bac

# copy bacon bin into the path
cp bacon /usr/sbin


Xdialog --title "Complete" \
           --infobox "\nInstalling bacon has finished.\n" 0 0 3000


   ;;
  1)
    echo "No chosen."
    exit
   ;;
  255)
    echo "Box closed."
    exit
   ;;

esac






Xdialog --wrap --title "test bac downloader" \
        --yesno "Do you want to download the bac examples   " 0 0

case $? in
  0)
    echo "Yes chosen."
   

# download and compile the 18  starter test files

###########################################
clean up old projects
rm -f  /root/bacon-examples/test*

cat << 'EOF' >/tmp/basic-examples
test1.bac
test2.bac
test3.bac
test4.bac
test5.bac
test6.bac
test7.bac
test8.bac
test9.bac
test10.bac
test11.bac
test12.bac
test13.bac
test14.bac
test15.bac
test16.bac
test17.bac
test18.bac
EOF

mkdir -p /root/bacon-examples
cd /root/bacon-examples  #note if not done it goes to root directory
MYURL="http://www.basic-converter.org/"


for i in `cat /tmp/basic-examples`
do xterm  -geometry 40x30+150+40 -e wget -c $MYURL$i


xterm  -geometry 40x30+150+40 -e bacon /root/bacon-examples/$i
Xdialog --title "testing compiler " \
           --infobox "\n$i compiled with bacon .\n" 0 0 3000


BAC_BIN=`basename  "$i" .bac`
xterm -hold  -geometry 40x30+150+40 -e /root/bacon-examples/$BAC_BIN

done
   ;;
  1)
    echo "No chosen."
    exit
   ;;
  255)
    echo "Box closed."
    exit
   ;;

esac


Code: Select all


#!/bin/sh

# call this dnd-bac-compiler

# a drag N drop bac  compiler    just drag N drop any *.bac file on the  
# script to compile it to a binary 
# run the binary by opening a terminal ./name of the binary 

xterm  -geometry 40x30+150+40 -e bacon "$@"
Last edited by big_bass on Mon 15 Nov 2010, 15:59, edited 4 times in total.

User avatar
vovchik
Posts: 1507
Joined: Tue 24 Oct 2006, 00:02
Location: Ukraine

comments and source

#28 Post by vovchik »

Dear Joe,

Thanks for the nice words. I have ported a few c examples and they are on Peter's site. I also have my original c sources so I can post them here. I will try to annotate my code (IMPORTS mainly), but I got those from studying the gtk/gdk/glade calls, looking at Peter's nearly complete gtk.bac and gdk.bac and glade.bac files and, in a few cases, winging it after looking at the var types needed by the calls. It becomes easier after a few "iterations" and you get a feel for it after few successes. I have an entire directory of c gtk gui samples and forced myself to translate a number of them to BaCon. It was a good exercise and, when I got stuck, I asked Peter, who knows all there is to know about BaCon and GTK (he also wrote GTK-server). If you get stuck, just holler :) Mechanic (Doyle) is doing a lot of gtk stuff in baCon and can provide some guidance.

With kind regards,
vovchik

big_bass
Posts: 1740
Joined: Mon 13 Aug 2007, 12:21

#29 Post by big_bass »

Hey vovchik

I am making a personal wish list for the next pikona


http://gnome-look.org/content/show.php? ... c0def5547c

there is no template to make those .......yet
if you could have a template for faenza_icons
with a rounded corner thin squared glass overlay
many new icons could be made

thanks

I wanted to bump this thread again too :D
Joe

User avatar
vovchik
Posts: 1507
Joined: Tue 24 Oct 2006, 00:02
Location: Ukraine

Faenza stuff

#30 Post by vovchik »

Dear Joe,

I am looking at the Faenza stuff now. It should be possible, so I will give it a try.:)

With kind regards,
vovchik

User avatar
vovchik
Posts: 1507
Joined: Tue 24 Oct 2006, 00:02
Location: Ukraine

Faenza icons

#31 Post by vovchik »

Dear Joe,

Here are some basic templates for faenza-style icons. I only made one overlay (to be placed in the ovl dir). The rest should go into the bgd dir (as in the archive). One of these days I will have to do a new pikona without the image-magick dependency, since I now know how to do that by calling the gdk libs. It's on my list.:)

With kind regards,
vovchik
Attachments
faenza-icn.jpg
(22.39 KiB) Downloaded 2404 times
faenza-bgd.jpg
(13.57 KiB) Downloaded 2655 times
faenza.tar.gz
(166.44 KiB) Downloaded 1192 times

big_bass
Posts: 1740
Joined: Mon 13 Aug 2007, 12:21

#32 Post by big_bass »

Hey vovchik
8) 8) 8)

Thank you, thank you, thank you!

what a great guy you are :D

it's perfect!

Joe
Attachments
faenza-puppylogo.png
(20.64 KiB) Downloaded 2448 times
mime-application.png
(13.33 KiB) Downloaded 2443 times
faenza_mime-application.png
(13.49 KiB) Downloaded 2368 times

User avatar
vovchik
Posts: 1507
Joined: Tue 24 Oct 2006, 00:02
Location: Ukraine

another overlay

#33 Post by vovchik »

Dear Joe,

Glad that I could be of service. I like the pup. Here is another overlay image that might be useful for faenza-style icons. It just provides a bit of shading for the lower part of the image.

With kind regards,
vovchik
Attachments
faenza-olb.png
(2.72 KiB) Downloaded 2347 times
pikona-faenza.jpg
(33.57 KiB) Downloaded 2427 times

big_bass
Posts: 1740
Joined: Mon 13 Aug 2007, 12:21

#34 Post by big_bass »

Hey vovchik

I was having a lot of fun with this today thank you again

I compile and package apps even though they look like slackware packages
because of the *tgz but they are not slackware official packages (they are better because they were recompiled from source on my machine the "imagemagick package" )
since I use slackware based formats on TXZ_pup
these should run fine on any "puppy version" in theory
I added these for anyone wanting to test out your excellent program
(I only repackaged it so others could enjoy your great app!)


pikona-002a-4_SLXR.tgz
http://www.puppy2.org/slaxer/pikona-002a-4_SLXR.tgz
this has the new faenza templates
and I added all the fixes and I added an apple ipod template
called AppIconMask.png ,AppIconOverlay.png , AppIconShadow.png

requires one dependency its stripped down to 1.9 mb
http://www.puppy2.org/slaxer/imagemagic ... 4_SLXR.tgz


extra only needed if you compile other packages requiring imagemagick
http://www.puppy2.org/slaxer/imagemagic ... 4_SLXR.tgz

extra the docs they are very large
http://www.puppy2.org/slaxer/imagemagic ... 4_SLXR.tgz

Joe

User avatar
vovchik
Posts: 1507
Joined: Tue 24 Oct 2006, 00:02
Location: Ukraine

pikona for slxr

#35 Post by vovchik »

Dear Joe,

Thanks for packaging it. I REALLY should do my mods soon so we can then skip the big IM stuff and just use the standalone BaCon binary.

With kind regards,
vovchik

User avatar
harii4
Posts: 448
Joined: Fri 30 Jan 2009, 04:08
Location: La Porte City, IA , U.S.A.
Contact:

#36 Post by harii4 »

I recommend starting an thread in - Desktop: Window managers, icon programs, widgets, etc.... section :)

that way this great tool can be found easier :D
Attachments
blank_ballet17_blank-128_80.png
(6.47 KiB) Downloaded 1872 times
3.01 Fat Free / Fire Hydrant featherweight/ TXZ_pup / 431JP2012
----------------------------------------------------------------------------------------
Peace and Justice are two sides of the same coin.

User avatar
Flash
Official Dog Handler
Posts: 13071
Joined: Wed 04 May 2005, 16:04
Location: Arizona USA

#37 Post by Flash »

I moved the whole thread to "Desktop" It was a tough call between Desktop, Eye candy, Graphics and Utilities. :)

scsijon
Posts: 1596
Joined: Thu 24 May 2007, 03:59
Location: the australian mallee
Contact:

#38 Post by scsijon »

witches and warlocks, bitches and dogs, etc, etc, girls and guys....

little confused on which files to download, does Joe's (big_bass) packages replace the others or are they in addition or what?

thanks
scsijon

User avatar
harii4
Posts: 448
Joined: Fri 30 Jan 2009, 04:08
Location: La Porte City, IA , U.S.A.
Contact:

#39 Post by harii4 »

@scsijon
pikona-002a-4_SLXR.tgz
http://www.puppy2.org/slaxer/pikona-002a-4_SLXR.tgz

this has the new faenza templates
and I added all the fixes and I added an apple ipod template
called AppIconMask.png ,AppIconOverlay.png , AppIconShadow.png

requires one dependency its stripped down to 1.9 mb
http://www.puppy2.org/slaxer/imagemagic ... 4_SLXR.tgz


extra only needed if you compile other packages requiring imagemagick
http://www.puppy2.org/slaxer/imagemagic ... 4_SLXR.tgz
i used these with TXZ_Pup but you could use tgz2pet for the other pups.
3.01 Fat Free / Fire Hydrant featherweight/ TXZ_pup / 431JP2012
----------------------------------------------------------------------------------------
Peace and Justice are two sides of the same coin.

User avatar
vovchik
Posts: 1507
Joined: Tue 24 Oct 2006, 00:02
Location: Ukraine

Pikona 4e released - no IM dependencies!!!!!!

#40 Post by vovchik »

Dear puppians,

I have rewritten Pikona, eliminated all IM dependencies and the binary is now about 29k. It should run fine on most recent puppies. Please see first post for details. More info is contained in the Pikona readme, which is accessible from the Pikona4 menu. The link is here: http://www.murga-linux.com/puppy/viewto ... 580#363580.

With kind regards,
vovchik

PS. The source is also in the pikona4-base.pet

Post Reply