News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Finding image on screen

Started by stbfish, October 04, 2009, 12:41:25 PM

Previous topic - Next topic

stbfish

i got a bmp format pic.(test.bmp)  then i want to get the pic's coordinate on screen.
any dll i can use. if not, any clue to do things like this.
thanks.

donkey

How is the image displayed on the desktop ? Is it in a window or is it integrated into the desktop wallpaper ?

If its in a window it can be found by using the window handle if its on the desktop you can do a simple pattern search to find the bitmap as long as its unique.
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

stbfish

first screenshot(full screen), then compare with test.bmp(a small block on screen), then get the test.bmp coordinate on screen.
sorry, my english is not good.i  hope my mean is clear now. :P :P

dedndave

i think you want to know about the BMP file format
for 24-bit BMP files, there is a 54 byte header, then each pixel takes 4 bytes - B, G, R, 0<-- always 0
the left pixel of the bottom image line is first in the file
some guy at microsoft had his hat on backwards when he designed the format - lol

hutch--

 :bg

> some guy at microsoft had his hat on backwards

Which endian ?  :P
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

dedndave

what endians ? - i didn't even see any arrows   :red

stbfish

Quote from: dedndave on October 05, 2009, 12:32:24 AM
i think you want to know about the BMP file format
for 24-bit BMP files, there is a 54 byte header, then each pixel takes 4 bytes - B, G, R, 0<-- always 0
the left pixel of the bottom image line is first in the file
some guy at microsoft had his hat on backwards when he designed the format - lol

2x2 Pixel, 24-Bit Bitmap
B G
R W
Hex view, the Bitmap Data show like below

0000FFFFFFFF0000FF000000FF000000

00 00 FF   0 0 255  Red, Pixel (1,0)
FF FF FF   255 255 255 White, Pixel (1,1)
00 00 0 0 Padding for 4 byte alignment (Could be a value other than zero)

3 bytes per pixel

found this on http://en.wikipedia.org/wiki/BMP_file_format


dedndave

if you want to handle a variety of BMP files, you should familiarize yourself with the header format
normally, i test the first 2 bytes to make sure it is a BMP file
then, i read the bits per pixel field so that i know how to interpret the rest of the file
the header is usually 54 bytes long, although, it can be longer (actually, they can add remarks etc.)
monochrome, 16 color, and 256 color files have a palette following the header
24 bit files need no palette, as each pixel is directly encoded
after that, you will want to know the dimensions of the image so you know how long a line is and how many there are
it is a good idea to verify the file size, as well, so that you know you have the entire image
uncompressed BMP files are probably the simplest of all graphics files to work with

FORTRANS

Hi,

Quote
the header is usually 54 bytes long, although, it can be longer

   It can be shorter as well.  Microsoft and IBM came up with the format,
and between the Windows and OS/2 versions....  And both extended
the definitions, presumably without talking to each other.

Quote
24 bit files need no palette, as each pixel is directly encoded

   But they can have one anyway.

Quote
after that, you will want to know the dimensions of the image so you know how long a line is and how many there are
it is a good idea to verify the file size, as well, so that you know you have the entire image

   And some header fields can be incorrect (one of the size fields
when it bit me).

Quote
uncompressed BMP files are probably the simplest of all graphics files to work with

   If you get them from a consistent source.  One of my favorite
image editing programs does not seem sane when creating BMP's.
Luckily 97% seem to play by the normal rules.

   The Targa TGA format is a bit simpler.  Though it too has version
and optional extensions.

   Uncompressed BMP is a good, easy start if you do some sanity
checks.  Or just use the right BMP's.

Regards,

Steve N.

P.S.  Just follow Dave's advice.  I collect images from (apparently)
bad places.

SRN

dedndave

if you do have a funky image - just load it into paint, then save it
that should straighten out the file format