Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

My own BitBlt

Posted on 2000-04-02
18
Medium Priority
?
417 Views
Last Modified: 2013-12-03
I would like to write my own BitBlt function, and my question is, how do you get a pixel from memory to the screen?  I've always had bad BAD luck with ASM and windows...  Can anyone point me in the right direction?

~Aaron
0
Comment
Question by:BudVVeezer
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 3
  • 3
  • +4
18 Comments
 
LVL 5

Expert Comment

by:laeuchli
ID: 2678477
Can't write to the screen directly in windows :-(. Even less so in NT. The only way to write to the screen is with the GUI, or directx.
0
 
LVL 5

Accepted Solution

by:
laeuchli earned 200 total points
ID: 2678480
Can't write to the screen directly in windows :-(. Even less so in NT. The only way to write to the screen is with the GUI, or directx.
0
 
LVL 3

Author Comment

by:BudVVeezer
ID: 2678493
that's a bunch of BS, I hate to tell it to you.  I know damn well you CAN write to the screen in Windows.  Maybe not in NT, but in 9x you sure can, because I've SEEN IT DONE.  You can write your own BitBlt function.

~Aaron
0
Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

 
LVL 3

Author Comment

by:BudVVeezer
ID: 2678494
If no one else can find a way to do it here, then I'll accept your answer, but you're jumping the gun a lot.  If it wasn't possible, I wouldn't have asked the question in the first place...but I have friends at DigiPen(who are on vacation right now and so not able to ask) who HAVE written Windows 9x BitBlts...

~Aaron
0
 
LVL 3

Author Comment

by:BudVVeezer
ID: 2678497
Let me rephrase my question so it's not so vague though.  If not to the screen, to a DC.  I know you can write your pixels somewhere in the DC(or maybe the screen) to achieve your own BitBlt

~Aaron
0
 
LVL 22

Expert Comment

by:nietod
ID: 2678530
You can use GetPixel()/SetPixel() to set individual pixels.  But it is VERY slow.  You can use GetDIBits and SetDIBits() to set pixels "in mass" This will be much faster.  Other than that, you really can't access the data inside a DC.  If the DC is for a hardware device, then only the device driver can access the memory.  (At least in 32 bits) so you can't touch the device's without writting a device driver.   If the DC is a memory DC, you still can't access the data directly because it is in a different address space.
0
 
LVL 3

Author Comment

by:BudVVeezer
ID: 2678537
::growls::Todd are you sure about that?  Cuz I KNOW there is a way to swing it...  It's a low level thing..  I know SetPixel is slow as all hell...  and I also know all about SetDIBits, etc..  but this isn't an API thing.  It's some lowlevel dealy that I saw Kirk do..  I'm gonna do some checking into these things..  gimme a day or so before I evaluate.

~Aaron
0
 
LVL 15

Expert Comment

by:NickRepin
ID: 2678551
Create DIB section and do whatever you want with the memory.
0
 
LVL 3

Author Comment

by:BudVVeezer
ID: 2678556
would you just use memcopy or memset or some other method to move the pixels around from the bitmap?

~Aaron
0
 
LVL 22

Expert Comment

by:nietod
ID: 2678582
Yes, but not when the bitmap is selected into a DC.  So there is really no difference between that and using GetDIBits/SetDIBits.
0
 
LVL 5

Expert Comment

by:laeuchli
ID: 2678605
In NT You can't write to screen memory directly. How do you know you can do it in 9x? That would crash the gui.
0
 
LVL 15

Expert Comment

by:NickRepin
ID: 2679011
>> but not when the bitmap is selected into a DC

IMHO, that is incorrect. You can select the dib section into a DC and then use the pixel pointer.
But on NT, it's necessary to call GdiFlush() before/after using a pointer.

Usually, I select dibsect into the memory device context, then change the bits, then bitblt to the screen.

It is faster than GetDibits because there is no need to use the intermediate buffer to transfer the large amount of pixels.
0
 
LVL 22

Expert Comment

by:nietod
ID: 2679774
Are you guaranteed that will work?  i.e. are you assured that the device will use the memory specified and not make a copy for example.  

>> It is faster than GetDibits because there is no
>> need to use the intermediate buffer
Agreed--if that is safe to do.   But depending on what you are doing, this difference may not matter.  If you are just setting pixels, then all you need is the SetDIBits(), in which case you may be looking at similar performance.
0
 
LVL 2

Expert Comment

by:xLs
ID: 2680459
BudVVeezer win9x/nt/win2k wil never let you access the video buffer directly, due to security, this could cause the operative system to crash if it would alow you to access the video address. this is the reason that microsoft invented directx, and dx will let you create a virtual framebuffer that you play around with as you like and you can blit it to the video buffer(primary surface) whenever you want.

Any other solution would sux because directx and bitblt is optimized and mostly using hardware blit so you would just loose a lot of speed if you try hack something on your own.

if you want a library with full source of framebuffer techniques check out
www.gaffer.org/ptc

it is portable over X/java/win32/dos etc..

good luck


0
 
LVL 15

Expert Comment

by:NickRepin
ID: 2681720
>>Are you guaranteed that will work?  

I'm sure that it works. I have used it several times. There is no restrictions in MS docs.
All work must be done on the memory device context (CreateCompatibleDC) - you have the full access to the MDC memory.
Then you have to just BitBlt result on the screen.

>>But depending on what you are doing, this difference may not matter.

May be, but in many cases you need to change only some pixels of the large bitmap. Also, IMHO, programming the DIB section is easier that the bitmap.

0
 
LVL 6

Expert Comment

by:snoegler
ID: 2681986
GetDesktopWindow()
GetDC()
BitBlt()

Let the desktop window render its contents into a memory DC (including child windows, WM_PRINT), then you have a snapshot of the desktop. Now you can either blit directly to the desktop window DC, or you can create a window which occupies the whole screen, blit the desktop windows contents' on it and then manipulate like you want.
0
 
LVL 2

Expert Comment

by:harrys
ID: 2733825
You could use DirectDraw for direct access to the screen. DD is available under any 32Bit Windows except NT prior to 4.0.

cu
0
 
LVL 3

Author Comment

by:BudVVeezer
ID: 2823571
::grumbles::sorry about how long it took me to respond to this...  I was getting done with school.  ;-P  I told you I would accept your comment as an answer if nothing better came along...and you were quasi-right to begin with.  It turns out I already knew how to do it(using GetDIBits) but it wasn't the avenue I was searching down.  Thanks though!

~Aaron
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, I will show how to use the Ribbon IDs Tool Window to assign the built-in Office icons to a ribbon button.  This tool will help us to find the OfficeImageId that corresponds to our desired built-in Office icon. The tool is part of…
A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question