Jump to content
  • Advertisement
Sign in to follow this  
turbello

TransparentBlt don't want to mirror an image

This topic is 2562 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi there, ( again ) :)

I'm trying to mirror my images but it is not working for an image that must have a transpareny color.

The following code is to mirror the image if there is no transparency: ( this is working )
[spoiler]

if( (pImage->MirrorHorizontal() == true) && (pImage->MirrorVertical() == true) )
{
StretchBlt( m_hDC, x, y, rect.right-rect.left, rect.bottom-rect.top, hdcmem, (rect.right-rect.left)-1,(rect.bottom-rect.top)-1, -(rect.right-rect.left), -(rect.bottom-rect.top), SRCCOPY );
}
else if( (pImage->MirrorHorizontal() == true) && (pImage->MirrorVertical() == false) )
{
StretchBlt( m_hDC, x, y, rect.right-rect.left, rect.bottom-rect.top, hdcmem, (rect.right-rect.left)-1, rect.top, -(rect.right-rect.left), rect.bottom-rect.top, SRCCOPY );
}
else if( (pImage->MirrorHorizontal() == false) && (pImage->MirrorVertical() == true) )
{
StretchBlt( m_hDC, x, y, rect.right-rect.left, rect.bottom-rect.top, hdcmem, rect.left, (rect.bottom-rect.top)-1, rect.right-rect.left, -(rect.bottom-rect.top), SRCCOPY );
}
else
{
StretchBlt( m_hDC, x, y, rect.right-rect.left, rect.bottom-rect.top, hdcmem, rect.left, rect.top, rect.right-rect.left, rect.bottom-rect.top, SRCCOPY );
}
[/spoiler]

To draw Images with a transparency I use this function:

TransparentBlt( m_hDC, x, y, rect.right-rect.left, rect.bottom-rect.top, hdcmem, rect.left, rect.top, rect.right-rect.left, rect.bottom-rect.top, pImage->GetTransparencyColor() );


And when I try to mirror the image like the same way I did with StretchBlt my image vanishes. :(

Do someone know why this not works with TransparentBlt, I've searched 20 sites for working properly with this function but I can't find something to mirror my image.


Kind Regards,
B. Jonathan

Share this post


Link to post
Share on other sites
Advertisement
Hidden
Wow I failed :blink:
I opened that site 7times and never read those lines. :unsure:


But now I can't mirror an image like that when I need transparency I was looking for something else.
And now, after 3hours of seaching on google how I could mirror an image very fast. ( So without set- getPixel ) I found something very interesting:

SetWorldTransform();

I have never heard of this function so I don't know how to work with this, so I've searched a half hour for tutorials and I just can't find a good tutorial how to work with this.



Before I start to render I'm making a compatibleBitmap that has the width and height of the window.


// HDC m_hDC
m_hDC = GetDC( m_hWnd );
// HDC m_hBufferDC
m_hBufferDC = CreateCompatibleDC(m_hDC);
// HBITMAP m_hBufferBmp
m_hBufferBmp = CreateCompatibleBitmap( m_hDC, iWidth, iHeight );
// HBITMAP m_hOldBmp
m_hOldBmp = (HBITMAP) SelectObject( m_hBufferDC, m_hBufferBmp );


I give my Painter class the 'HDC m_hBufferDC' to draw lines,images,rectangles, etc. This is for doublebuffering.
So when I need to draw something I use m_hBufferDC as destination and another compatibleDC to the m_hBufferDC that will be the source.

Before I stop to render:


BitBlt( m_hDC, 0, 0, this->GetWindowWidth(), this->GetWindowHeight(), m_hBufferDC, 0, 0, SRCCOPY );

SelectObject(m_hBufferDC, m_hOldBmp);
DeleteObject(m_hBufferBmp);
DeleteDC(m_hBufferDC);


So this is normally my 'World' where I can draw some bitmaps in.
So now I need to give every Bitmap I load into the game his own 'World' so he can rotate/translate/etc.

But my world must remain because I want to have the same world to look at.

But I can't find a good tutorial that shows how to do this. :( I waisted 5hours already for just looking after a way to rotate/mirror images and I'm still waisting time with seaching for a nice tutorial. <_<



If someone could help me.. THANK YOU!!

Share this post


Link to post
Hidden
Ok after 4 more hours I found some code to test.

I first tested to rotate text. This works perfectly. But when I try, with the same code, to rotate a bitmap the bitmap really don't want to rotate very well.

But that 's not a big problem. I found how to mirror the bitmaps and that was the point of this.

But now I got a second problem. I need to cut out a piece of the Bitmap because it is a spritesheet.
So I work with a RECT rect to cut a piece out of it.

This is my RECT I use to get the first image from the Bitmap:
RECT r = {0, 0, 64, 64};

If I mirror the Bitmap I want to cut out the new first image in the Bitmap. But this doens't seem to work. My image is still te same. How can I fix this?
TransparentBlt(
hDC, 0, 0, rect.right-rect.left, rect.bottom-rect.top, hdcmem, rect.left, rect.top, rect.right-rect.left, rect.bottom-rect.top, RGB(252,252,252) );


Kind Regards,
B. Jonathan

Share this post


Link to post
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!