• Print

Author Topic: Concepts topic  (Read 307 times)

DarthWho

  • Hero Member
  • *****
  • Posts: 3853
  • Timelord of the Sith
Concepts topic
« on: June 14, 2012, 09:47:59 PM »
essentially the idea behind this topic is for those who are less proficient in languages that are capable of making libraries to propose ideas for functions that they would like to see but are unable to implement themselves; the Idea here is fo those who lack the skill to suggest ideas for libraries they would like to see implemented (EX: a single variable calculus library Note: I am already working on said library it'll be called the FastCalcSV library [it is not guaranteed to be particularly fast it is just a name that fits with the standard I have set with the FastMath lib])
and those who have the skills if they become interested can then take it from here and start work possibly setting up another topic and collaborating if it interests multiple programmers with the needed skillset.
Rassilon: My lord Doctor; My lord Master; My lord DarthWho
The Doctor and the master at the same time :WHAT!?!?!

FastMath 1.1.0 released: http://dl.dropbox.com/u/12359848/fastmath.h

SMcNeill

  • Hero Member
  • *****
  • Posts: 2414
    • Email
Re: Concepts topic
« Reply #1 on: November 28, 2012, 02:18:16 PM »
Could someone convert this C# to QB64?   It's a nice little snip it that allows alt-print screen to save a windowed screenshot to file.  My C is just too weak to make the needed swap ovet to something that would be QB64able.

Code: [Select]
Here is something to start to capture and save to a file. You will just need to hook the key "Print screen".

using System;
using System.Drawing;
using System.IO;
using System.Drawing.Imaging;
using System.Runtime.InteropServices;
public class CaptureScreen
{

static public void Main(string[] args)
{

try
{
Bitmap capture = CaptureScreen.GetDesktopImage();
string file = Path.Combine(Environment.CurrentDirectory, "screen.gif");
ImageFormat format = ImageFormat.Gif;
capture.Save(file, format);
}
catch (Exception e)
{
Console.WriteLine(e);
}

}

public static Bitmap GetDesktopImage()
{
WIN32_API.SIZE size;

IntPtr hDC = WIN32_API.GetDC(WIN32_API.GetDesktopWindow());
IntPtr hMemDC = WIN32_API.CreateCompatibleDC(hDC);

size.cx = WIN32_API.GetSystemMetrics(WIN32_API.SM_CXSCREEN);
size.cy = WIN32_API.GetSystemMetrics(WIN32_API.SM_CYSCREEN);

m_HBitmap = WIN32_API.CreateCompatibleBitmap(hDC, size.cx, size.cy);

if (m_HBitmap!=IntPtr.Zero)
{
IntPtr hOld = (IntPtr) WIN32_API.SelectObject(hMemDC, m_HBitmap);
WIN32_API.BitBlt(hMemDC, 0, 0,size.cx,size.cy, hDC, 0, 0, WIN32_API.SRCCOPY);
WIN32_API.SelectObject(hMemDC, hOld);
WIN32_API.DeleteDC(hMemDC);
WIN32_API.ReleaseDC(WIN32_API.GetDesktopWindow(), hDC);
return System.Drawing.Image.FromHbitmap(m_HBitmap);
}
return null;
}

protected static IntPtr m_HBitmap;
}

public class WIN32_API
{
public struct SIZE
{
public int cx;
public int cy;
}
public  const int SRCCOPY = 13369376;
public  const int SM_CXSCREEN=0;
public  const int SM_CYSCREEN=1;

[DllImport("gdi32.dll",EntryPoint="DeleteDC")]
public static extern IntPtr DeleteDC(IntPtr hDc);

[DllImport("gdi32.dll",EntryPoint="DeleteObject")]
public static extern IntPtr DeleteObject(IntPtr hDc);

[DllImport("gdi32.dll",EntryPoint="BitBlt")]
public static extern bool BitBlt(IntPtr hdcDest,int xDest,int yDest,int wDest,int hDest,IntPtr hdcSource,int xSrc,int ySrc,int RasterOp);

[DllImport ("gdi32.dll",EntryPoint="CreateCompatibleBitmap")]
public static extern IntPtr CreateCompatibleBitmap(IntPtr hdc, int nWidth, int nHeight);

[DllImport ("gdi32.dll",EntryPoint="CreateCompatibleDC")]
public static extern IntPtr CreateCompatibleDC(IntPtr hdc);

[DllImport ("gdi32.dll",EntryPoint="SelectObject")]
public static extern IntPtr SelectObject(IntPtr hdc,IntPtr bmp);

[DllImport("user32.dll", EntryPoint="GetDesktopWindow")]
public static extern IntPtr GetDesktopWindow();

[DllImport("user32.dll",EntryPoint="GetDC")]
public static extern IntPtr GetDC(IntPtr ptr);

[DllImport("user32.dll",EntryPoint="GetSystemMetrics")]
public static extern int GetSystemMetrics(int abc);

[DllImport("user32.dll",EntryPoint="GetWindowDC")]
public static extern IntPtr GetWindowDC(Int32 ptr);

[DllImport("user32.dll",EntryPoint="ReleaseDC")]
public static extern IntPtr ReleaseDC(IntPtr hWnd,IntPtr hDc);
}


Code taken from: http://stackoverflow.com/questions/158151/how-can-i-save-a-screenshot-directly-to-a-file-in-windows
http://bit.ly/TextImage -- Library of QB64 code to manipulate text and images, as a BM library.
http://bit.ly/Color32 -- A set of color CONST for use in 32 bit mode, as a BI library.

http://bit.ly/DataToDrive - A set of routines to quickly and easily get data to and from the disk.  BI and BM files

Mrwhy

  • Hero Member
  • *****
  • Posts: 2893
  • My Dad called me Mr Why when I was 5.
    • Email
Re: Concepts topic
« Reply #2 on: November 29, 2012, 03:08:30 AM »
Quote from: DarthWho on June 14, 2012, 09:47:59 PM
essentially the idea behind this topic is for those who are less proficient in languages that are capable of making libraries to propose ideas for functions that they would like to see but are unable to implement themselves; the Idea here is fo those who lack the skill to suggest ideas for libraries they would like to see implemented (EX: a single variable calculus library

Good idea Darth

Usually the problem is NOT just the code language.
It is knowing the right maths jargon! For example "calculus" "differential" etc etc etc
A person wants to follow the detail changes along a curve. How can he be expected to know differential calculus is one of the many relevant buzz words!
Knowing the qb codewords is just as bad.
A person speaks English. He says "I want to draw a curve from point A to point C, visiting point B.
Who would know (except by  trial and error) that "circle" is relevant, nor how to make it so.
« Last Edit: November 29, 2012, 03:21:13 AM by Mrwhy »

  • Print