Imgconvert Image Converter

This tool works great for converting pictures or clipboard objects to pictures It supports JPEG Bitmap Icons and Metafiles. It can draw directly to the screen or default printer. Very simple and easy to do. Great for photographers !

To see how to use it just unzip the .DLL file and .exe file to a folder and type imgconvert.exe to see the help page

unit imgconvert1;

interface
uses windows,classes,graphics,sysutils,jpeg,clipbrd,printers,controls,scanimg,
mmsystem;
function delphianMain(parameters:tstringlist):DWORD;
type
EOutFileType=class(Exception);
{$RESOURCE IMGCONVERT32.RES}
implementation

procedure ScreenShot(Bild: TBitMap);
var
  c: TCanvas;
  r,desk: TRect;
begin
  c := TCanvas.Create;
  getwindowrect(getdesktopwindow,desk);
  c.Handle := GetWindowDC(GetDesktopWindow);
  try
    r := Rect(0, 0,desk.right, desk.bottom);
    Bild.Width := desk.right;
    Bild.Height := desk.bottom;
    Bild.Canvas.CopyRect(r, c, r);
  finally
    ReleaseDC(0, c.Handle);
    c.Free;
  end;
end;

procedure ScreenShotActiveWindow(Bild: TBitMap);
var
  c: TCanvas;
  r, t: TRect;
  h: THandle;
begin
  c := TCanvas.Create;
  c.Handle := GetWindowDC(GetDesktopWindow);
  h := GetForeGroundWindow;
  if h <> 0 then
    GetWindowRect(h, t);
  try
    r := Rect(0, 0, t.Right - t.Left, t.Bottom - t.Top);
    Bild.Width  := t.Right - t.Left;
    Bild.Height := t.Bottom - t.Top;
    Bild.Canvas.CopyRect(r, c, t);
  finally
    ReleaseDC(0, c.Handle);
    c.Free;
  end;
end;
function GetConsoleWindow:hwnd;stdcall;external'kernel32.dll';
procedure screenshotfrommouse(bild:tbitmap);
var mouse:tpoint;
  c: TCanvas;
  r, t: TRect;
  h: THandle;
begin
  c := TCanvas.Create;
  playsound('SNAP',HInstance,snd_resource or snd_sync);
  getcursorpos(mouse);
  c.Handle := GetWindowDC(GetDesktopWindow);
  h := windowfrompoint(mouse);
  if h <> 0 then
    GetWindowRect(h, t);
  try
    r := Rect(0, 0, t.Right - t.Left, t.Bottom - t.Top);
    Bild.Width  := t.Right - t.Left;
    Bild.Height := t.Bottom - t.Top;
    Bild.Canvas.CopyRect(r, c, t);
  finally
    ReleaseDC(0, c.Handle);
    c.Free;
  end;
end;

function ReadScanner:tbitmap;
begin
result:=tbitmap.Create;
TWAIN_SelectImageSource(getconsolewindow);
  if (TWAIN_LoadSourceManager >0) Then
  Begin
if (TWAIN_AcquireToClipboard(getconsolewindow,TWAIN_ANYTYPE)>0)
    Then
      result.LoadFromClipboardFormat(
          cf_BitMap,
          ClipBoard.GetAsHandle(cf_Bitmap),
          0
        );
    ClipBoard.Clear;
    TWAIN_UnLoadSourceManager;
  End;
end;

function GetGIFFile(filename:PChar):hbitmap;stdcall;external'gifview.dll';

function delphianMain(parameters:tstringlist):DWORD;
//Main Function
var pic:tpicture;
desktop:tcanvas;
sshot,bmp:tbitmap;
text,extout,extin:String;
ico:ticon;
il:timagelist;
i:integer;
jpg:tjpegimage;
htxt:thandle;
written:dword;
mf:tmetafile;
begin
result:=0;
if parameters.Count<2 then begin
writeln('Usage: ',extractfilename(paramstr(0)),' picture_read picture_write [/monochrome]');
writeln('Converts picture_read to picture_write file format');
writeln('Formats supported(Read and write formats): BMP,JPG,ICO');
writeln('Read-only formats: GIF,WMF,EMF');
writeln('Set picture_read to clipboard and a filename ending .TXT to create a text file from clipboard');
writeln('Set picture_read to scan: to scan a picture');
writeln('Set picture read to screen:mouse to capture the window where the mouse is covering');
writeln('Set picture_read to screen: to capture the entire screen.');
writeln('Set picture_read to window: to capture the window behind the console window.');
writeln('Set picture_write to screen: to write to the screen');
writeln('set picture_write to print: to print the picture');
writeln(
'Set either or both picture_read or picture_write to clipboard: to import or export from the clipboard');
writeln('Press enter to return...');
readln;
exit;
end;
try
pic:=tpicture.Create;
extin:=extractfileext(parameters[0]);
extout:=extractfileext(parameters[1]);
if(StrIComp('.emf',pchar(extin))=0)then begin
mf:=tmetafile.Create;
mf.Enhanced:=true;
mf.LoadFromFile(parameters[0]);
pic.Bitmap.Height:=mf.Height;
pic.Bitmap.Width:=mf.Width;
pic.Bitmap.Canvas.Draw(0,0,mf);
end else if(StrIComp('.wmf',pchar(extin))=0)then begin
mf:=tmetafile.Create;
mf.Enhanced:=false;
mf.LoadFromFile(parameters[0]);
pic.Bitmap.Height:=mf.Height;
pic.Bitmap.Width:=mf.Width;
pic.Bitmap.Canvas.Draw(0,0,mf);
end else
if stricomp('screen:mouse',pchar(parameters[0]))=0then begin
writeln('Screenshot will begin in...');
for i:=10downto 1do begin writeln(i,' seconds...');sleep(1000);end;
sshot:=tbitmap.Create;
screenshotfrommouse(sshot);
pic.Bitmap.Handle:=sshot.Handle;
end else
if stricomp('scan:',pchar(parameters[0]))=0 then pic.Bitmap:=readscanner else
if pos('text:',lowercase(parameters[0]))=1then
begin
text:=copy(parameters[0],6,maxint);
pic.Bitmap.height:=pic.Bitmap.Canvas.TextHeight(text);
pic.Bitmap.Width:=pic.Bitmap.Canvas.TextWidth(text);
pic.Bitmap.Canvas.TextOut(0,0,text);
end else if stricomp('screen:',pchar(parameters[0]))=0then
begin
showwindow(getconsolewindow,sw_hide);
sshot:=tbitmap.Create;
screenshot(sshot);
pic.Bitmap.Handle:=sshot.Handle;
showwindow(getconsolewindow,sw_show);
end else if stricomp('window:',pchar(parameters[0]))=0then
begin
showwindow(getconsolewindow,sw_hide);
sshot:=tbitmap.Create;
screenshotactivewindow(sshot);
pic.Bitmap.Handle:=sshot.Handle;
showwindow(getconsolewindow,sw_show);
end else if stricomp('clipboard:',PChar(parameters[0]))=0then begin
if stricomp('.txt',pchar(extout))=0then
text:=clipboard.AsText else
pic.Assign(clipboard);
end else if stricomp('.gif',pchar(extractfileext(parameters[0])))=0 then
pic.Bitmap.Handle:= getgiffile(pchar(parameters[0]))else
pic.LoadFromFile(Parameters[0]);
if parameters.IndexOf('/monochrome')>-1then pic.Bitmap.Monochrome:=true;
if stricomp('clipboard:',pchar(parameters[1]))=0then clipboard.Assign(pic)else
if stricomp('screen:',pchar(parameters[1]))=0then begin
desktop:=tcanvas.Create;
desktop.Handle:=getwindowdc(getdesktopwindow);
desktop.Draw(0,0,pic.Graphic);
desktop.Free;
end else if stricomp('print:',pchar(parameters[1]))=0then begin
printer.BeginDoc;
printer.Canvas.Draw((printer.pagewidth - pic.graphic.width) div 2,
(printer.PageHeight-pic.graphic.height div 2),pic.Graphic);
printer.EndDoc;
end else if(stricomp('.txt',pchar(extout))=0)and(stricomp('clipboard:',
pchar(parameters[0]))=0)then begin
htxt:=createfile(pchar(parameters[1]),generic_write,file_share_read or
file_share_write,nil,create_always,file_attribute_normal,0);
if htxt=invalid_handle_value then begin writeln('Create:',syserrormessage(
getlasterror));result:=getlasterror;exit;end;
if not writefile(htxt,text[1],length(text),written,nil) then begin writeln('Write:',
syserrormessage(getlasterror));result:=getlasterror;closehandle(htxt);exit;end;
closehandle(htxt);
end else
if stricomp('.bmp',pchar(extout))=0then
pic.Bitmap.savetofile(parameters[1]) else
if stricomp('.ico',pchar(extout))=0 then begin
ico:=ticon.Create;
bmp:=tbitmap.Create;
if(stricomp('.jpg',pchar(extin))=0)or(stricomp('.jpeg',pchar(extin))=0)then begin
jpg:=tjpegimage.Create;
jpg.LoadFromFile(parameters[0]);
bmp.Assign(jpg);
end else if(stricomp('.bmp',pchar(extin))=0)then
bmp.Handle:=pic.Bitmap.Handle else
if(stricomp('.gif',pchar(extin))=0)then
bmp.Handle:=getgiffile(pchar(parameters[0]))else
if(stricomp('.emf',PChar(extin))=0)then
begin
mf:=tmetafile.Create;
mf.Enhanced:=true;
mf.LoadFromFile(parameters[0]);
bmp.Height:=mf.Height;bmp.Width:=mf.Width;
bmp.Canvas.Draw(0,0,mf);
end else if(stricomp('.wmf',PChar(extin))=0)then
begin
mf:=tmetafile.Create;
mf.Enhanced:=false;
mf.LoadFromFile(parameters[0]);
bmp.Height:=mf.Height;bmp.Width:=mf.Width;
bmp.Canvas.Draw(0,0,mf);
end;
il:= timagelist.CreateSize(bmp.width,bmp.height);
il.AddMasked(bmp,bmp.TransparentColor);
il.GetIcon(0,ico);
ico.SaveToFile(parameters[1]);
end else if(stricomp('.jpg',pchar(extout))=0)or(stricomp('.jpeg',pchar(extout))=0)
then begin
jpg:=tjpegimage.Create;
jpg.assign(pic.bitmap);
jpg.savetofile(parameters[1]);
end else
raise eoutfiletype.Create('Unknown file type: '+extout);
except on e:exception do begin result:=getlasterror;writeln('Error:',e.message);
exit;end;
end;
writeln('Picture converted successfully');
end;

end.

All programs are virus free. Some antivirus software might say its "suspicious" or a "Potentionaly Unwanted Program". Some of them rate them on what there code looks like no matter if theres a definition in the virus database. If any of them are detected any Antivirus I will zip the software with the password "justin" j is lowercase

Published by Justin Roeder

I am an electronics engineer and computer programmer that has autism. I learned by myself

delphijustin Industries is an Autism Supported Business
Social Media Auto Publish Powered By : XYZScripts.com
All in one
Start
OVH Hosting 01 Singapore
Your cart is empty.
Loading...