Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void drawBitmapTransparence(Bitmap* bmp, int x, int y, Alignment alignment) {
- if (bmp == NULL){
- return;
- }
- int width = bmp->bitmapInfoHeader.width;
- int drawWidth = width;
- int height = bmp->bitmapInfoHeader.height;
- if (alignment == ALIGN_CENTER)
- x -= width / 2;
- else if (alignment == ALIGN_RIGHT)
- x -= width;
- if (x + width < 0 || x > get_Hres() || y + height < 0
- || y > get_Vres())
- return;
- int xCorrection = 0;
- if (x < 0) {
- xCorrection = -x;
- drawWidth -= xCorrection;
- x = 0;
- if (drawWidth > get_Hres())
- drawWidth = get_Hres();
- } else if (x + drawWidth >= get_Hres()) {
- drawWidth = get_Hres() - x;
- }
- char* bufferStartPos;
- char* imgStartPos;
- for (y = y1; y < height; y++) {
- for (x = x1; x < width; x++) {
- if((*imgStartPos | ((*(imgStartPos + 1))))!=Green)
- draw_pixel(x, y, color);
- int pos = y + height - 1 - i;
- if (pos < 0 || pos >= get_Vres())
- continue;
- bufferStartPos = getGraphicsBuffer();
- bufferStartPos += (x * 2 + pos * get_Hres()) * 2;
- imgStartPos = bmp->bitmapData + xCorrection * 2 + i * width * 2;
- memcpy(bufferStartPos, imgStartPos, drawWidth * 2);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement