Getting pixels from a clipboard DIB, the quick and painless solution.

I appologize in advance for the lack of indentation, once again internet text-editors fail to take indentation into account.
LPARAM GetDIBPixelsFromClipboard(HWND clipboardOwnerWnd, COLORREF* returnPixels){
//Open clipboard
BOOL testOpen=OpenClipboard(clipboardOwnerWnd);
cout<<“Could not open clipboard for some reason.”<<endl;
return 0;
//See if there’s a DIB saved to the clipboard (MS Paint throws them up there in this format)
HGLOBAL test=GetClipboardData(CF_DIB);
cout<<“No bitmap saved to the clipboard.”<<endl;
return 0;
//Aquire BITMAPINFO struct
const BITMAPINFO* bmi=(BITMAPINFO*)GlobalLock(test);
//The packed pixel array is after the information for the BITMAPINFO struct, it must be referenced by incrimenting the memory spot for the BITMAPINFO pointer past the RGBQUAD[1] section.
//That section is reached quickly by the bmiHeader.biSize member, this array of bytes is padded with zero-bytes of variable amount after each row of pixels, we will be filtering these zero-bytes below.
LPSTR colors=((LPSTR)bmi+bmi->bmiHeader.biSize);
//This is the count of bytes that represent a row of pixels plus the padding bytes
LONG limit=((((bmi->bmiHeader.biWidth*bmi->bmiHeader.biBitCount)+31)&~31)>>3);
//This is the width of each row before it gets to the padding bytes, this is how many actual bytes represent the red, green, and blue color channels of each pixel in the row exclusively.
LONG rowWidth=bmi->bmiHeader.biWidth*3;
//The length of the padding bytes
int padding=limit-rowWidth;
//The length of the DIB in pixels (the size of the bitmap)
LONG size=bmi->bmiHeader.biWidth*bmi->bmiHeader.biHeight;
//Related stuff. Extents for height and width, and also an iterator for the loops below.
LONG c=0;
LONG xExt=bmi->bmiHeader.biWidth;
LONG yExt=bmi->bmiHeader.biHeight;
/*Declare two COLORREF arrays, one to recieve the bytes upside down, and one to convert the upside down pixels to the correct way,there may be a more efficient way to do this if necessary, but this way works just fine.*/
COLORREF* upsideDownPixels=new COLORREF[size];
COLORREF* pixels=new COLORREF[size];
     //Here is where you loop through the DIB section of the BITMAPINFO struct, which is referenced by (colors).
for(LONG i=0;i<size;i++){
           //This is the part where the zero-bytes for the row-padding get filtered.
for(int j=0;j<padding;j++)colors++;
//Colors are assigned here by the individual color channel and then combined to represent a single pixel.
    //From here we aquire the upside down representation of the bitmap’s pixels
unsigned char r=*colors;colors++;
unsigned char g=*colors;colors++;
unsigned char b=*colors;colors++;
//Now that we have the upside down bitmap’s pixels lets flip them vertically
for(LONG y=bmi->bmiHeader.biHeight-1;y>-1;y–){
for(LONG x=0;x<bmi->bmiHeader.biWidth;x++){
//Delete memory that is no longer necessary, unlock the locked clipboard variable, and close the clipboard.
delete [] upsideDownPixels;
//Assign (returnPixels) to (pixels) so that they can be referenced after this function executes.
//Return the width and height of the bitmap so that (returnPixels) can be looped through acurately.
//You can reference the width and height by using LOWORD(returnValueOfThisFunction) and HIWORD(returnValueOfThisFunction) respectively.
return MAKELPARAM(xExt,yExt);
Posted in Uncategorized | Tagged , , , , | Leave a comment

How “Undo” works in Notepad.

This is a full-on explanation of how Undo works in Notepad.exe, and how I’m making it work in my own text editor.

First off, I’m almost finished creating an edit control from scratch which will be capable of everything the leading text editors are, and one more secret surprise which totally slays.

First off lets look at what actually happens here.

As it turns out when ever you type into notepad a position is saved, a whole range is actually saved from A{line_number,char_index} to B{line_number,char_index} and everything typed or pasted will remain within that range, and if the position is deviated from via arrow keys or mouse, or backspace/delete too (I think) then the beginning of the range and end of the range are set to what ever the current caret position is, but only after a char is typed or something is pasted, and if that position deviates from the old position then it creates the new range starting from that point. When an undo command is sent what happens is it takes that range and deletes all of the characters in it, and Redo would simply put them back, which would mean that just before Undo is running it stores the saved text in a set of strings which it then inserts back into place if an Undo was made, this would be the most efficient way of doing it, probably the way Microsoft’s team did it.

I’ve seen a few forum posts about this so I’m posting it here hoping the next person making their own edit control will google this and my blog post will show up and help the guy out.


==========================Update April 2, 2013=======================

I did it, a few weeks ago I got Undo working perfectly for every type of edit, and I did it the way I was thinking, it worked out, but it ended up twisting my mind into knots to actually get working, it’s really difficult to explain really but I did not use files, and I did not use copies of all of the text data before a change was made.

Instead I used text ranges, and string vectors for reversing the Undo (Redo). I put all of the information into an UNDO_STRUCT which has a text range, two booleans for which kind of deletion, backspace or delete, when reversing a backspace I had to literally reverse the characters before inserting back into the main output strings.

For each type of editing of text, (Typing printable characters, deleting one character, deleting a range of characters, etc..etc..etc…) I split them into groups and let a function determine which type of change was made.

For each type of editing change there is a set of instructions on what is done for Undo. For example if you clicked somewhere the position would be saved in a position struct {line,char}, and when ever you type anything it records everything you type right up until the edit type changes, which means you decided to do anything else aside from typing printable characters, and the position variable would simply follow the cursor and wait for it to change position either via arrow keys, home/end,clicking the mouse somewhere else, etc.. and it would test to see whether the current mouse position matched it. If at any point before (something else) is done the user selects Undo from the right-click menu, or via ctrl+V then it saves the newly typed information in a vector of strings, and then it erases the range from the beginning position to the current cursor position, and then if a redo is made it simply pastes the text right back in place where it was deleted, and thus a perfect undo/redo of typing a range of characters was done.

You literally have to sit and think about how many different ways there are of editing text, and make different sets of instructions for each, surprisingly there really aren’t a whole lot of different groups you have to split it into. The groups I used were:

+ user types printable characters:
– letters
– numbers
– symbols
+ user hits enter
+ user hits del
+ user hits backspace
+ user hits spacebar
+ user hits tab
+ user cuts
+ user pastes
+ user deletes

Those are all the different ways of undoing, the first one, listed “user typed printable characters:” encompasses the letters, numbers, symbols all as the same group.

You see, what I am building here is the world’s greatest text-editor. Never before has there been one like it, I plan to smoke all competition with a range of popularly used features and some features unique only to it, AND I intend for it to run as smoothly and lightly as notepad, right now the program weighs just over half a megabyte and it does everything it should in basic-text-editor terms, and I have line numbers, I could pass this off as a fully functional edit control as it is but I’m going to really soup it up with optional features, I will make them optional in order to keep it optionally efficient, at the very least as efficient as notepad. The features for this text editor will be vast and useful, I plan to make it freeware but closed source, I will sell the source code to the sickest text-editor ever made, but users totally benefit free, I plan to sell the source code to Microsoft when it’s finished and let them improve on it and sell their version or add it to their Visual Studio environment or wherever it’s useful, this program will be the finest of it’s kind in the entire known universe.

Posted in Uncategorized | Leave a comment

Detecting top level window movement without a global message hook

First thing you want to do is et the foreground window using GetForegroundWindow since that’s the only window capable of being moved by the user, and then repeatedly test it’s coordinates using GetWindowRect, set a timer to around 100 milliseconds or so, what ever feels right, when the timer event triggers set one rectangle’s coordinates then return , and then next time it triggers set the other rectangle’s coordinates and return, over and over and repeatedly test for a change in RECT coordinates, in short you’re basically getting the coordinates to two different rectangle’s based on the foreground window’s rectangular coordinates each fraction of a second to see if the coordinates are different, and if they are then the window was moved.

That’s basically it, no global hooks needed.


Posted in Uncategorized | Tagged , , , | Leave a comment

Also, to add to my compression theory blog a REALLY bit-level-efficient compression LANGUAGE could be made, and stored in bytes at the beginning of the file (like how a dictionary algorithm works) and it can teach the decompressor how to process different pieces of information.


Some times I just think about compression algorithms in my never-ending quest for a perfect random data compressor, well I had a very good concept of how this could be done and I just thought about another which would totally compliment it so I might chase the recursive compression algorithm dream again, the first idea I had was simply to have it mark sections based on a single character known at run time, selected based on a number of times the character is found, that way no extra bits are needed to signal information since it’s already there in the first place, so one extra byte could easily represent two bytes in a number of easily imaginable ways when you know how to programmatically break down a byte to it’s 8 containing bits, and vice-versa, gives you a bit more to work with, you can divide those bits into sections…

View original post 351 more words

Posted in Uncategorized | Leave a comment

My thoughts on compression algorithms. -I’ll post another with my own ideas for actual compression algorithms rather than just this far out theory crapola-

Some times I just think about compression algorithms in my never-ending quest for a perfect random data compressor, well I had a very good concept of how this could be done and I just thought about another which would totally compliment it so I might chase the recursive compression algorithm dream again, the first idea I had was simply to have it mark sections based on a single character known at run time, selected based on a number of times the character is found, that way no extra bits are needed to signal information since it’s already there in the first place, so one extra byte could easily represent two bytes in a number of easily imaginable ways when you know how to programmatically break down a byte to it’s 8 containing bits, and vice-versa, gives you a bit more to work with, you can divide those bits into sections, I would use the first two bits to signal that the preceding information is to be either untouched or represented in which of three ways, three different potential ways to convert data into less-memory-intensive representations of it, one of those ways is a very standard used method of RLE encoding, which is where you’re using a byte-vector, you could think of the next byte as a marker to it’s self, or in vector terminology a direction, and every byte afterward until the next byte changes value as your magnitude. Thus representing it as [243][01|100011] is a way of visualizing “Repeat this byte (number 243) 35 times” represented as only two bytes, instead of 35. Shortening the whole of all of the data by a whopping 30 bytes, this is mainly done large-scale as a basic lossless bitmap encoding method, which is heavily reliant on pixel redundancy, and the [01| would be the part of the command byte that says “Hey, use RLE with this one”.
Command identifiers could mean one of three other things, including do not touch, but this idea could be scaled up to several bytes, to a point where enough command information could be stored to signify the patterns found by a self-learning artificially intelligent pattern recognizer could, efficient algorithms could be made right on the spot, and unlike a dictionary algorithm it would teach this to a cloud program which would say “Hey, there’s this new thing called such and such, and it processes data this way, whenever these first few bytes of the file are found do it exactly like this, this is the best possible compression method for this particular file.”, I guess if it hasn’t been invented yet it could be invented soon since cloud computing is going to be talked about and utilized more and more in the coming times, which I think is neat but potentially shitty, I think of it as.. the internet…for the internet? :p Anyway, this post turned out way longer than I expected so I’m just going to blog this one and leave a link here on fagbook.

Posted in Uncategorized | Tagged , , , , , | 1 Comment

A certain laughable social trend…

Honestly, and this is to all wiggers who read this blog entry nobody gives a shit about…

Do you ever question the whole wearing your pants down past your ass crack, wearing dorags, throwing up gang signs, and hollaring “EES siEEEEED”? Honestly, is THAT what REALLY looks cool to you? It doesn’t look retarded in any way to you? REALLY? Come on.. You’ve GOT to agree at least in SOME way right?

Also, what about R&B sounds good to you? I really want to know, I haven’t yet heard one R&B song that didn’t sound as extremely bland as the last. It’s a woman’s music not a man’s. Men don’t need feelings we like action, it’s how it is right? Someone help me out here.

I can totally understand if it’s just to please the women (which explains the whole R&B thing) but what exactly looks attractive about flat top hats? That looks cool to you nigger-lover chicks? WHY DOES THAT APPEAL TO YOU? I’m sorry I just think it looks terrible, brings on the impression that a man is lacking in intellectual capabilities, takes what he wants from the physically weaker or easily intimidated out of ignorance that most of them really aren’t as tough as they claim, therefore being a bully by nature, and making society that much more difficult to bear for the average human being.

Is that what everybody prides themselve’s on these days? What about actually being a productive member of society that people can be proud to be a friend of? Imagine knowing Nikola Tesla, actually having his friendship, THAT’S cool, and back in his day women LOVED Nikola Tesla, he refused the company of women over being alone, and working on his projects making the world a better place to live in, giving us all the gifts of his discoveries.

What do you do? Wiggers are often the opposite of everything good and right in the world, getting attention from young women or naive older women who don’t know better, and due to society’s mass influence based on fear and ignorance you look good to them somehow, but not to an educated woman who prides herself on being a benefactor to humanity, yeah you social chameleon fucks like to pretend to share their opinions as well to get into their pants, but the whole reason isn’t even to get your rocks off, it’s to look good in the naive social circles of the world. The reason I even say that is because I happen to know there’s a very prevalent gay side to the whole “Thug life” thing, don’t believe me? Google search “Thug life sexuality” and you’ll see enough links revealing the gayness of ghetto boy life. So while you’re acting all hard core calling geeks faggots you fail to neglect that your cultural background is very gay-friendly indeed, do you not see it for yourself judging from your gay-friendly clothing styles? Thug-culture is secretly gay-culture, and you’ll begin to see it more and more as thug-culture evolves further and further down the road to metrosexuality, you already listen to the music of those you consider the weakest people of any culture, “da bichez”. You’re listening to woman music, wearing your pants down to your knees (which btw in prison that’s how gays dress sexy for their boyfriends).

So for your own benefit, you might want to just come out of the closet, I think society would respect you more as gays than as wiggers since gays are more realistic about who they are. I certainly respect gays a LOT more than anyone claiming to be tough because he’s from “da skreetz yo”, such things are only said by those that are highly insecure, and scared to admit something deep down and penetrating.

You might think you look tough with your prison bitch pants and your Tapout shirt, but remember this, in the court of law (run by intellectuals) and any of the true controlling powers of the world (the ACTUAL “bawsses”) are anything BUT what you are, you’re a pawn to the real thugs, which are more along the lines of educated intelligent people and you get intellectually AND financially punked by them if given the moment to actually meet one from your low-end area of life. They’re the Joneses that you’ll never keep up with, the ones whome acknowledge you as the worthless sleaze that you are.

Posted in Uncategorized | Tagged , , , , , , | Leave a comment

Conventional music theory is a fucking joke to me..

I’ve been a self-taught musician for a decade and a half, never learned music theory outside of conversations with “experts”, generally people who needed school to learn music, but  some times they get pissed about the fact that I didn’t NEED conventional music theory to do make music, it doesn’t matter to them whether I got my point across, it just bothered them that I never cared to learn the conventional style, I do not find it beneficial at all learning things the conventional way, going to school, all of that stupid shit, I don’t like school and I never will, I learn things intuitively when I’m interested enough in them, here are my gripes about “music theory”.

First off, let me begin with what’s known as an octave, this is one of my biggest gripes ever and one of the reasons I’ll always hate music theory as it’s taught, octaves are calculated on the premise of notes, there are 8 notes in an octave in music theory, this is what I hate, first off there are 12 useful conventional tones in an octave, THOSE are what should be counted as notes, not this stupid A,B,C,D,E,and F shits limited to 8 uniform tones, and the stupid sharps and flat BULLSHIT, fuck all of that, we’re going to talk about music theory according to ME now, because imo conventional music theory is WRONG and LIMITING. First off I want to rename the octave to “dodecave” because that is the greek cardinal for 12, because damnit, there are 12 tones, everything else is a dodecave, screw limited octaves which serve only the pretentious, dodecaves are less limiting, less conventional but more realistic, any guitarist/pianist/melodic instrument player of any kind knows this internally but is taught the word “octave” and the notes by letters bullshit, but here’s how I would put it all in letter terms, bear with me now…

A,B,C,D,E,F,G,H,I,J,K,L, those are the notes, and to signify WHICH dodecave you’re on, a simple number next to the letter would perfectly signify it. For example A1=A-tone at a dodecave of 1, I imagine this would be based on a technical pitch-standard of some sort, I usually consider the first dodecave to be around the general area of a conventional-style E-note when tuning a guitar, that should be the beginning of the first dodecave, and any that go below that first dodecave (like for a bass guitar or other really low-note instrument) can be signified with negative numbers, or some sort of small symbol, it’s better this way because it’s more orderly in a hierarchial fashion, which is far more neocortex-friendly.

Next I would like to touch on how sheet music is written, how unintuitive it is looking at those strange symbols that mean nothing and look stupid, I hate the appearance of sheet music tbh, but since it has a use it should at least be modified more intuitively, I don’t know about the rest of the world but I see music structurally in my mind when I hear it, it’s involuntary, it’s synesthetic, music theory should be based on this, perhaps it would produce a naturally synesthetic brain mapping of music like I have, which is incredibly intuitive, I can judge the sonic distance of ANY two differently-pitched tones just by hearing them, and looking at the structure formed in my mind, everything I’m ranting about here is based off the structure and colors that I see in my mind when I hear music, or any kind of sound for that matter.  People need to realize there is and there isn’t an order to sound, there is because of music, there isn’t because naturally sound is just waves of pressure moving through the air, that’s all it is, frequencies. Frequencies being a very good term, as it stems from the word “frequent”, which is how often something happens, in the case of sound it’s how often the waves of pressure hit your ear, the closer those waves of pressure are together the faster your ear recieves them as a frequency, and the higher the pitch of tone it will be. To speed up these ripples of pressure in the air is to change the pitch of a tone to a higher pitch, lower frequencies are your bass tones and higher frequencies are your lead notes and such. Picture it as someone going “Wha wha wha” really fast in your ear, so fast that they can make any tone just by varying the speed of those “wha”s until they sound like a single tone oscillating rapidly.

I didn’t always see the structure of tones until I became a player of instruments but the colors per-tone were always there, and they change depending on the pitch of a progression of tones, structure and pitch are what show up when it’s all said and done.

I think everybody has the ability to see music for how it’s actually depicted by nature, those that do realize they have it also realize that there is a 12-basic-tone limit to ALL MUSIC EVER MADE, and to ALL MUSIC THAT CAN EVER BE MADE. You get 12 tones to work with and that’s it, everything else is a dodecave variant of those 12 tones, forget about 8 notes an octave, I don’t know how we made it that far musically with just that, sure, those 8 tones we think of as notes are merely selected as the sweet tones, the tones that go together in any fashion and sound good, but the problem with that is you’re neglecting 4 more tones that could be used, and since the world has overused every single note in an octave in every single pattern useable over and over and over, I personally like to acknowledge and use the 4 tones that conventional music theorists like to avoid, I find them to be metal personally and they fit great in avant garde styles of music.

So to everyone conventional, you’d be making a huge mistake trying to one-up me, I’ll shit all over you with my natural understanding of what took you much time and effort to be taught in school.

Posted in Uncategorized | Tagged , , , | Leave a comment

Hack for sending drag/drop from an application to another application..

Hack for sending drag/drop from an application to another application...

Posted in Uncategorized | Leave a comment

Hack for sending drag/drop from an application to another application..

I’ve been looking for a way to do this all day long and nothing but failure and wasted time has come of it.
I saw every tutorial and example, tried everything in between just to avoid having to use COM interfaces, I hate those, I HATE COM! I hate that Microshaft only caters to programmers using their shitty IDE, I’m a purist C++ programmer, I use the standard GNU style compiler and I set my compiler to C++ mode and use more of a C-dialect with the exception of using the new/delete operators. The last thing I want to hear is that I have to use COM now to do drag/drop operations, fuck that noise. I didn’t have a problem with this on Windows XP, had it working fine then, but now Windows 7 doesn’t want to cooperate, so for all you pissed-off C programmers, here we go…

First thing you want to do when trying to send drop data to another folder or the desktop is once you have your drop point positioned and you’re ready to drop, at that point you’re looking for a window, you’re going to check whether the top parent of said window is a folder window or the desktop, if it’s a folder window then you can search through the hierarchy and find the address bar who’s title will contain a string like this “Address: C:\path\to\somewhere”, so what you wanna do with that is take out the “Address: ” part, add another slash to the end, and then a file you want to transfer through the drag/drop operation, once you do that you take the resulting string and use it with CopyFile, or MoveFile, or what ever. If the target window is the desktop then it will probably be NULL if I’m not mistaken, and then you can do your file operation sending it to the desktop.

I haven’t yet tried this yet, just theoretically, I bet a million dollars I will get it working tomarro using this method when I get back on it.

Basically what I’m making is an explorer window that’s able to do basic file operations like drag/drop to recieve, the drag/dropping of recieved files to folders/the desktop, and probably executing files after double-clicked, this project will be finished soon thanks to a little deep outside-the-box thought. Because I will NOT be forced to use COM objects for something as simple as a drag/drop operation, fuck that!

Well it is now slightly past tomarro night and I finished the drag/drop hack several hours ago, and well, if it were a legit bet I’d be a millionaire right now, everything worked out perfectly just as I stated it would, but it wasn’t quite as easy, I decided to use the program Spy++ which comes with Microshaft’s VC++ compiler/IDE, I used it to navigate through the windows visually before using FindWindowEx and GetParent to programmatically grab the necessary child windows that lead to the address bar.

Posted in Uncategorized | Tagged , , , , , , , , , , , | 1 Comment

Hello world!

Welcome to! This is your very first post. Click the Edit link to modify or delete it, or start a new post. If you like, use this post to tell readers why you started this blog and what you plan to do with it.

Happy blogging!

Posted in Uncategorized | 1 Comment