opiumhautopium1 Posted February 21, 2012 Share Posted February 21, 2012 the question is is it possilble 1 to find a uniqe color from a bmp like BitmapFromString(9, 10, 'beNpjYKAQfH/thVPquRM5usi' + 'TwmsXFD13wmMCCAAAda0XwQ=='); and give a output of that color like hpcolor1:=4318 found 1 time 2) is it possilble to output all colores and times in the given bmp? 3 is it possible to count a given color in a bmp? hpcolor1:=4318 found 2 times hpcolor2:=8390 found 3 times hpcolor3:=5924327 found 2 times hpcolor4:=10413found 10 times hpcolor5:=12453....... at the moment i know how to find colors in a aktiv window or area but not inside a bmp and i dont know if it possible at all°° thx in advance Quote Link to comment Share on other sites More sharing options...
shadowrecon Posted February 21, 2012 Share Posted February 21, 2012 (edited) Yes, and Yes. 1 GetBitmapAreaColors returns a T2dIntArray of all colors found on the Bitmap. 2 If you set the bitmap as the target you can use any color finding routines. Just make sure you save the client handle before doing so and set it back after you do you color finding methods. Heres a function i wrote you can look at it for reference: Note: It takes a bmp specified by B which is a box off of client, and returns all colors found. [scar]function BMPColor(Const B: TBox): T2DIntArray; var PB, W, H: Integer; Client: Hwnd; begin Client := GetClientWindowHandle; Try PB := BitmapFromString(B.X2 - B.X1, B.Y2 - B.Y1, ''); CopyClientToBitmap(PB, B.X1, B.Y1, B.X2, B.Y2); SetTargetBitmap(PB); GetBitmapSize(PB, W, H); Result := GetBitmapAreaColors(0, 0, W - 1, H - 1); except Finally SetClientWindowHandle(Client); FreeBitmap(PB); end; end; [/scar] Edited February 21, 2012 by shadowrecon Quote Link to comment Share on other sites More sharing options...
opiumhautopium1 Posted February 22, 2012 Author Share Posted February 22, 2012 old man goes on his knees and thx a lot Quote Link to comment Share on other sites More sharing options...
opiumhautopium1 Posted February 23, 2012 Author Share Posted February 23, 2012 so i am a bloody idiot try to handle.......... i am to stupid here is a bmp i want to check can u show me how to handle with this bmp please? bmp := BitmapFromString(7, 14, 'beNoBJgHZ/nF1PC8pOSsiRz' + 'UpZVNHFwMANyohXUtBY1FHOCYYnZGIUDkqhWtex7+yWUM4PysgaF' + 'RI7uvpt6OX28Cy39nJbFZJqqGZ9PHu////+fj1w722VUY64dTEdl' + '9VblRN+ff2oZB6vKGW0Lisw7Woo4iBdFVStq2pp4x3oIN7UDwxCA' + 'AA3tHItKGbZ1xVUEEuDQAANCMZpZ2SBAAABwAAGhUScmpfJyEVCw' + 'AAFxAIt6qiZlRQNCgsPiwqGQoDHRAIPzsyCAICOjQ0NS8zTkhMV1' + 'FTSUdIIyMjPz8/MzM1R0dJTEtQLCswExQYIyQoR0dHLi4wSUlLMT' + 'A1KCcsLS4yMzQ4Nzc3RUVHKSkrXFtgYWBlUVJWP0BEGBgYHh4gQE' + 'BCLCswNzY7W1xgcMNJZpU='); Quote Link to comment Share on other sites More sharing options...
shadowrecon Posted February 23, 2012 Share Posted February 23, 2012 Okay what are you trying to do? Get a Color from it? Or Find the bmp? Quote Link to comment Share on other sites More sharing options...
opiumhautopium1 Posted February 23, 2012 Author Share Posted February 23, 2012 i want to get the colors and how many times they are in this bitmap Quote Link to comment Share on other sites More sharing options...
shadowrecon Posted February 23, 2012 Share Posted February 23, 2012 (edited) Okay here is how you do that : [Note there are many methods but this one is simple quick and works] [scar]Procedure GetColors2; var BMP, W, H, I, NC: Integer; ATIA: T2DIntArray; Client: Hwnd; begin BMP := BitmapFromString(7, 14, 'beNoBJgHZ/nF1PC8pOSsiRz' + 'UpZVNHFwMANyohXUtBY1FHOCYYnZGIUDkqhWtex7+yWUM4PysgaF' + 'RI7uvpt6OX28Cy39nJbFZJqqGZ9PHu////+fj1w722VUY64dTEdl' + '9VblRN+ff2oZB6vKGW0Lisw7Woo4iBdFVStq2pp4x3oIN7UDwxCA' + 'AA3tHItKGbZ1xVUEEuDQAANCMZpZ2SBAAABwAAGhUScmpfJyEVCw' + 'AAFxAIt6qiZlRQNCgsPiwqGQoDHRAIPzsyCAICOjQ0NS8zTkhMV1' + 'FTSUdIIyMjPz8/MzM1R0dJTEtQLCswExQYIyQoR0dHLi4wSUlLMT' + 'A1KCcsLS4yMzQ4Nzc3RUVHKSkrXFtgYWBlUVJWP0BEGBgYHh4gQE' + 'BCLCswNzY7W1xgcMNJZpU='); Client := GetClientWindowHandle; SetTargetBitmap(BMP); GetBitmapSize(BMP, W, H); ATIA := GetBitmapAreaColors(0, 0, W - 1, H - 1); FreeBitmap(BMP); SetClientWindowHandle(Client); for I := 0 to High(ATIA) do Begin TIAUnique(ATIA); // Remove all dueplicates TIARemoveEx(ATIA,0,True); // Removes any empty slots IncEx(NC,Length(ATIA)); // number of colors WriteLn('Colors In ATIA['+IntToStr(I)+']: '+TIAToStr(ATIA)); end; Writeln('Number Of Colors: '+IntToStr(NC)); end;[/scar] Colors In ATIA[0]: 2699068,4673891,2108223,10068394,5594998,8489123,13160926,4,10660535,131592,4144959,4671303,3618615,1579032Colors In ATIA[1]: 2239289,1582648,4740200,15659508,5067886,5395828,10199476,7,5264486,3421242,3486515,3157550,4670789,2104862Colors In ATIA[2]: 2700615,8950173,15330286,16777215,16185337,11120054,5594215,1185050,2893876,3354421,4802375,4933961,2828585,4341824Colors In ATIA[3]: 4674405,2767184,9937847,16120057,8032417,7834791,3031376,6253170,2763838,4999246,5262156,3485745,6314844,3156780Colors In ATIA[4]: 791,6187909,11714779,11976131,9871804,8094624,13,1384743,199193,5460311,3156780,2893608,6643809,3880503Colors In ATIA[5]: 2173495,11714503,13228511,3819093,11319504,3226704,1647412,11,528413,4736841,1578003,3288621,5657169,6315099Colors In ATIA[6]: 4279133,3687257,4806252,12899553,11056579,8,9608613,528407,3291967,2302755,2630691,3683379,4472895,7696752Number Of Colors: 98[/Code][color=Silver] [size=1]---------- Post added at 11:19 AM ---------- Previous post was at 10:46 AM ----------[/size] [/color]Or if you just want to count the colors then do this...: [ This could be put in a loop with the data found by the first function and would print out all of the data ][scar] Procedure GetNumberOfColor(Color: Integer);var BMP, W, H,NC: Integer; Client: Hwnd;begin BMP := BitmapFromString(7, 14, 'beNoBJgHZ/nF1PC8pOSsiRz' + 'UpZVNHFwMANyohXUtBY1FHOCYYnZGIUDkqhWtex7+yWUM4PysgaF' + 'RI7uvpt6OX28Cy39nJbFZJqqGZ9PHu////+fj1w722VUY64dTEdl' + '9VblRN+ff2oZB6vKGW0Lisw7Woo4iBdFVStq2pp4x3oIN7UDwxCA' + 'AA3tHItKGbZ1xVUEEuDQAANCMZpZ2SBAAABwAAGhUScmpfJyEVCw' + 'AAFxAIt6qiZlRQNCgsPiwqGQoDHRAIPzsyCAICOjQ0NS8zTkhMV1' + 'FTSUdIIyMjPz8/MzM1R0dJTEtQLCswExQYIyQoR0dHLi4wSUlLMT' + 'A1KCcsLS4yMzQ4Nzc3RUVHKSkrXFtgYWBlUVJWP0BEGBgYHh4gQE' + 'BCLCswNzY7W1xgcMNJZpU='); Client := GetClientWindowHandle; SetTargetBitmap(BMP); GetBitmapSize(BMP, W, H); NC := CountColor(Color,0,0,W-1,H-1); FreeBitmap(BMP); SetClientWindowHandle(Client); Writeln('# Of Times '+IntToStr(Color)+' Was Found: '+IntToStr(NC));end; Begin GetNumberOfColor(2699068);end.[/scar] [Code] # Of Times 2699068 Was Found: 1 [/Code] Edited February 23, 2012 by shadowrecon Quote Link to comment Share on other sites More sharing options...
opiumhautopium1 Posted February 23, 2012 Author Share Posted February 23, 2012 you make an old man very happy ;-P thx a lot exaktly that i was looking for Quote Link to comment Share on other sites More sharing options...