#๐ setbitmapbits is not an ATTRIBUTE????
102 messages ยท Page 1 of 1 (latest)
@modern kelp
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
Traceback (most recent call last):
File "C:\Users****\Desktop\visual glitch\COOL.py", line 95, in <module>
screenshot.SetBitmapBits(hue_shifted_array.tobytes())
AttributeError: 'PyCBitmap' object has no attribute 'SetBitmapBits'
idk i dont know as well i just saw this in a tutorial that got nearly no views
maybe not a great tutorial?
ye but how do i do it then cuz i gotta edit the memory by Extracting which i can do
but
i cant put it back into the mem_smth
have you checked what methods it does have then?
yes
and?
The error is clear, the object doesn't have such setter.
And why do you want to set it? You don't use that screenshot variable anywhere after, you do blt later with something else
wdym
they often get these things wrong
so how can i fix it
cuz i need a way to retrieve and set data manually unlike mem_dc.BitBlt((0, 0), (width, height), dc, (0, 0), win32con.SRCCOPY)
Those hints in IDE guessed from type hints, they are not always reflecting the truth
well maybe first use dir() to check what methods it does actually have
like I suggested earlier
how do i do that
that function returns a list of attributes the object has
so screenshot.dir()
no, dir(screenshot) and do something with the return value
ok
['AttachObject', 'CreateCompatibleBitmap', 'GetAttachedObject', 'GetBitmapBits', 'GetHandle', 'GetInfo', 'GetSize', 'LoadBitmap', 'LoadBitmapFile', 'LoadPPMFile', 'Paint', 'SaveBitmapFile', 'class', 'delattr', 'dir', 'doc', 'eq', 'format', 'ge', 'getattribute', 'gt', 'hash', 'init', 'init_subclass', 'le', 'lt', 'ne', 'new', 'reduce', 'reduce_ex', 'repr', 'setattr', 'sizeof', 'str', 'subclasshook']
Btw this is the firs time i have used win32 so idk anything basically
I haven't used it either, but looks like the method you're looking to use doesn't exist there
so do i just not set the bitmapbits and just select the object? but then i havent saved the changes onto the screenshot
so it wont get applied
if you want to alter the screenshot, maybe use Pillow for that
"doesn't work"?
pillow has no way to "directly" alter the data, it has to retrieve, alter then change the value to the altered value
but then win32 has given no way to change the value
what alterations are you looking to make then?
so import it to Pillow and then use its API to make the changes?
yes thats what im trying to do but then when i try to put it back Onto the screenshot so that i can send it into the mem_dc, it doesnt work cuz theres no way to put it back onto the screenshot
what's that supposed to do then
you take a screenshot, then alter its hue, then what?
you take a screenshot, make a duplicate that pillow can use, and then try to replace the original screenshot with the duplicate
but i cant do the last step
this code gets the screenshot and immediately puts it into the memory but i dont know how to turn it into the screenshot like this does
mem_dc.BitBlt((0, 0), (width, height), dc, (0, 0), win32con.SRCCOPY)
"replace the original" - this part I don't understand
what is the practical thing you want to achieve after altering the hue?
value1 = 1
value1copy = value1
value1copy += 1 <----- changing the hue
value1 = value1copy
this doesn't tell me anything
im trying to make a copy and then reassigning screenshot to be the copy
pillow cant do effects on the screenshot so i need to make a copy, turn it into the format that pillow can use
can you please just answer my simple question
afterwards i take the screenshot and make the tearing effect and put it on screen
if random.choice([True, False]):
x_start = random.randint(0, width - 1)
x_end = random.randint(x_start, width)
y_offset = random.randint(-40, 40)
dc.BitBlt(
(x_start, y_offset),
(x_end - x_start, height - abs(y_offset)),
mem_dc,
(x_start, 0),
win32con.SRCCOPY
)
else:
y_start = random.randint(0, height - 1)
y_end = random.randint(y_start, height)
x_offset = random.randint(-40, 40)
dc.BitBlt(
(x_offset, y_start),
(width - abs(x_offset), y_end - y_start),
mem_dc,
(0, y_start),
win32con.SRCCOPY
)```
ok, so "displaying the altered screenshot" was the answer
and can that not be done with Pillow?
would this not work? https://nitratine.net/blog/post/how-to-take-a-screenshot-in-python-using-pil/
yes but i dont know how format back into the way that win32 can display it
meaning you can't figure out how to make Pillow display images on the screen?
no i want pillow to alter, then Somehow change it back into the format that win32 can use so that win32 displays it directly instead of pillow showing on like a window
by directly you mean in full screen?
would a borderless screen-sized window not work?
no because you cannot interact with the rest of the operating system such as other apps
i want it so that it like goes rainbow on the screen while you can use other apps
like a filter on screen
yes cuz if i only do the tearing effect, it works, i can also draw on screen, that works
but i cant make a hue changeeffect
then IDK
And how do you do that alteration? Since the screenshot object doesn't have the SetBitmapBits, but you got it to work
wdym@faint plank
you mean the tearing effect
and the line effect
OHHH I used dc
using dc i captured the screen and put it into mem_dc i think
I capture using dc and then put it into mem_dc, then i display the stuff in mem_dc by sending it back to dc using BitBlt
for the draw theres a draw attribure for dc
Yep. Dc seems to be something related to display, screenshot is just a c bitmap.
As I said previously, in the current code you didn't even plan how to use the screenshot after writing to it - there's some blt later, but it didn't use the screenshot variable. That's what clued me in that you maybe don't need to change screenshot var, just blt whatever you need
wdym i dont use the screenshot for the screen tearing effect tho
i just display it at different positions
using dc
You don't use the screenshot variable in the if/else part.
so how to fix
Use the bit blt thing to write mem_dc directly to dc, just like you did with the tearing.
Instead of trying to write mem_dc to the screenshot variable
but how do i use pillow then because its not in a format that pillow can use
I don't mean to get rid of the whole screenshot variable, just the part where you try to write to it (the SetBitmapBits part)
Instead we just need to find how to write numpy array (the type of your hue_shifted_array) to dc
That means we gotta convert numpy array to a type it can accept
It only accepts the bitmap variable(screenshot) that Win32 makes I think
If I also don't write to the screenshot variable, then why should we have it
@faint plank
This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.