Página 1 de 2

Dll: ImageToIcoPabloko.dll

Publicado: 15 Abr 2011 14:19
por Pabloko
Hola, el otro dia me puse con el amigo Ceone a hacer un programita C# command line para convertir imagenes (de cualquier tipo) en iconos compatibles para los putos listboxex y toda esa jaruña.

Como entre unas cosas y otras consegui exportar dlls de assamblies C# diractamente lo he metido en una dll asi que al lio:

ImageToIco(string "from", string "to", int size (0-XXX), int mode(1=mantener aspecto:0=resimensionar)):stdcall

ejemplo:
function ImageToIco(strFROM, strTORu, nNSize, copyVal)
	local DLLFile = _SourceFolder.."\\AutoPlay\\Docs\\ImageToIcoPabloko.dll";
	local arg = "\""..strFROM.."\",\""..strTORu.."\","..nNSize..","..copyVal
	
	DLL.CallFunction(DLLFile, "ImageToIco", arg, DLL_RETURN_TYPE_INTEGER, DLL_CALL_STDCALL);
end


strFROM = _SourceFolder.."\\AutoPlay\\Images\\name.bmp";
strTORu = _SourceFolder.."\\AutoPlay\\Icons\\name.ico";
ICOSize = 32;
copyVal = 1;

ImageToIco(strFROM, strTORu, nNSize, copyVal);
Descargar:
HIDE: ON
Hidebb Message Hidden Description


Or On Mediafire by abood1987 : :friends:

HIDE: ON
Hidebb Message Hidden Description


Codigo fuente de la dll:
using System;
using System.Collections.Generic;
using System.Text;
using RGiesecke.DllExport;



using System.Media;
//using System.Text;
using System.Drawing;
using System.Data;
using System.IO;
using System.Reflection;



namespace ImageToIcoPabloko
{
internal static class UnmanagedExports
{
[DllExport("ImageToIco", CallingConvention = System.Runtime.InteropServices.CallingConvention.StdCall)]
static void ImageToIco(string from, string to, int size, int copy)
{
Image im = Image.FromFile(from);

int i = size;
int ic = copy;

Icon kon;

if (ic == 1)
{
kon = MakeIcon(im, i, true);
}
else
{
kon = MakeIcon(im, i, false);
}

FileStream fs = File.Create(to);

kon.Save(fs);
fs.Flush();
kon.Dispose();
fs.Close();
fs = null;
}

static public Icon MakeIcon(Image img, int size, bool keepAspectRatio)
{
Bitmap square = new Bitmap(size, size); // create new bitmap
Graphics g = Graphics.FromImage(square); // allow drawing to it

int x, y, w, h; // dimensions for new image

if (!keepAspectRatio || img.Height == img.Width)
{
// just fill the square
x = y = 0; // set x and y to 0
w = h = size; // set width and height to size
}
else
{
// work out the aspect ratio
float r = (float)img.Width / (float)img.Height;

// set dimensions accordingly to fit inside size^2 square
if (r > 1)
{ // w is bigger, so divide h by r
w = size;
h = (int)((float)size / r);
x = 0; y = (size - h) / 2; // center the image
}
else
{ // h is bigger, so multiply w by r
w = (int)((float)size * r);
h = size;
y = 0; x = (size - w) / 2; // center the image
}
}

// make the image shrink nicely by using HighQualityBicubic mode
g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
g.DrawImage(img, x, y, w, h); // draw image with specified dimensions
g.Flush(); // make sure all drawing operations complete before we get the icon

// following line would work directly on any image, but then
// it wouldn't look as nice.
return Icon.FromHandle(square.GetHicon());
}
}
}

Re: Dll: ImageToIcoPabloko.dll

Publicado: 15 Abr 2011 14:39
por Ceone
Imagen

visionario ;) "C#" yeah^^

Re: Dll: ImageToIcoPabloko.dll

Publicado: 16 Abr 2011 11:12
por aass
esto me viene muy bien, gracias

Re: Dll: ImageToIcoPabloko.dll

Publicado: 16 Abr 2011 23:25
por carsonzillo
fú yeagh!

Re: Dll: ImageToIcoPabloko.dll

Publicado: 28 Abr 2011 09:12
por xxsolracxx
gracias

Re: Dll: ImageToIcoPabloko.dll

Publicado: 28 Abr 2011 15:52
por dangngocnguyenit
thanks 

Re: Dll: ImageToIcoPabloko.dll

Publicado: 02 May 2011 12:34
por er_mejor
gracias, me servirá de ayuda!

Re: Dll: ImageToIcoPabloko.dll

Publicado: 04 May 2011 15:51
por Phaelitico
Muy bueno :D

Re: Dll: ImageToIcoPabloko.dll

Publicado: 07 May 2011 23:05
por abood1987
gracias

Re: Dll: ImageToIcoPabloko.dll

Publicado: 19 Ago 2011 18:30
por sSantoss
SE ve buena XD..

Re: Dll: ImageToIcoPabloko.dll

Publicado: 22 Ago 2011 19:48
por erickdj
Gracias
Imagen

Re: Dll: ImageToIcoPabloko.dll

Publicado: 21 Nov 2011 16:46
por Haitham.2012
<span style="color:#804000">WE NEED MORE THANK U
</span>

Publicado: 21 Oct 2013 21:10
por amsuser24
:friends:

Publicado: 22 Oct 2013 07:17
por jackdaniels
Hello,

Can you please reupload the dll ?

Re:

Publicado: 26 Oct 2013 11:17
por jackdaniels
jackdaniels escribió:Hello,

Can you please reupload the dll ?

Publicado: 28 Oct 2013 19:25
por nightmare3519
THANKS bro

Publicado: 01 Nov 2013 02:26
por zero29
lo voy a checaar grasiasa

Publicado: 03 Ene 2014 17:46
por amsplug
;) :) :yes: :sorry:

Publicado: 06 Ene 2014 18:28
por mohsen
thanks

Publicado: 06 Ene 2014 20:41
por abood1987
the Link has been Update to the Mediafire Server ;) :friends: 6/1/2014
by abood1987