// ----------------------------------------------------------------------------- // Calculates the decode size and prepares members for scaling. // ----------------------------------------------------------------------------- // TSize CMPXImageUtil::CalculateDecodeSize(const TSize& aSize) { const TFrameInfo& frameInfo = iImageDecoder->FrameInfo(); TSize bitmapSize = frameInfo.iOverallSizeInPixels; TReal sourceAspectRatio( TReal( bitmapSize.iWidth) / bitmapSize.iHeight ); TReal destinationAspectRatio( TReal( aSize.iWidth ) / aSize.iHeight ); TReal xScale = TReal( bitmapSize.iWidth ) / aSize.iWidth; TReal yScale = TReal( bitmapSize.iHeight ) / aSize.iHeight; TReal scale(0.0f); if ( sourceAspectRatio > destinationAspectRatio ) { scale = xScale; iSize.iWidth = aSize.iWidth; iSize.iHeight = Stretch( TReal( bitmapSize.iHeight ) / scale , aSize.iHeight ); } else { scale = yScale; iSize.iWidth = Stretch( TReal( bitmapSize.iWidth ) / scale , aSize.iWidth); iSize.iHeight = aSize.iHeight; } if ((frameInfo.iFlags & TFrameInfo::EFullyScaleable)) { iScaleRquired = EFalse; bitmapSize = iSize; } else //Decoder only supports 2, 4 and 8 scallyng, the image will need //to be reescaled after decoding. //Decoding to a scale that is just a bit bigger thant the target, //this will save memory and resources and we will get a sharp image //after scaling. { TInt intscale = ( scale >= 8 ) ? 8 : ( scale >= 4 ) ? 4 : ( scale >= 2 ) ? 2 : 1; TUint xCorrection = ( bitmapSize.iWidth % intscale ) ? 1 : 0; TUint yCorrection = ( bitmapSize.iHeight % intscale ) ? 1 : 0; bitmapSize.iWidth /= intscale; bitmapSize.iHeight /= intscale; bitmapSize += TSize( xCorrection, yCorrection ); iScaleRquired = ETrue; } return bitmapSize; }
void Canvas::StretchMono(int dest_x, int dest_y, unsigned dest_width, unsigned dest_height, const Bitmap &src, int src_x, int src_y, unsigned src_width, unsigned src_height, Color fg_color, Color bg_color) { assert(IsDefined()); assert(src.IsDefined()); #ifndef _WIN32_WCE if (bg_color == COLOR_BLACK && (src_width != dest_width || src_height != dest_height)) { /* workaround for a WINE bug: stretching a mono bitmap ignores the text color; this kludge makes the text color white */ SetTextColor(COLOR_BLACK); SetBackgroundColor(COLOR_WHITE); Stretch(dest_x, dest_y, dest_width, dest_height, src, src_x, src_y, src_width, src_height, MERGEPAINT); return; } #endif /* on GDI, monochrome bitmaps are special: they are painted with the destination HDC's current colors */ SetTextColor(fg_color); SetBackgroundTransparent(); Stretch(dest_x, dest_y, dest_width, dest_height, src, src_x, src_y, src_width, src_height); }
void Bitmap::drawShadow(Bitmap & where, int x, int y, int intensity, Color color, double scale, bool facingRight) const { const double newheight = getHeight() * scale; Bitmap shade(getWidth(), (int) fabs(newheight)); Stretch(shade); /* Could be slow, but meh, lets do it for now to make it look like a real shadow */ for (int h = 0; h < shade.getHeight(); ++h){ for (int w = 0; w < shade.getWidth(); ++w){ Color pix = shade.getPixel(w, h); if (pix != MaskColor()){ shade.putPixel(w, h, color); } } } transBlender(0, 0, 0, intensity); if (scale > 0){ if (facingRight){ shade.translucent().drawVFlip(x, y, where); } else { shade.translucent().drawHVFlip(x, y, where); } } else if (scale < 0){ y -= fabs(newheight); if (facingRight){ shade.translucent().draw(x + 3, y, where); } else { shade.translucent().drawHFlip(x - 3, y, where); } } }
void StretchedBitmap::finish(){ if (getData() != where.getData()){ switch (filter){ case NoFilter: Stretch(where); break; case HqxFilter: { if (scaleToFilter.getWidth() > 1 && scaleToFilter.getHeight() > 1){ StretchHqx(scaleToFilter); scaleToFilter.Stretch(where); } else { StretchHqx(where); } break; } case XbrFilter: { if (scaleToFilter.getWidth() > 1 && scaleToFilter.getHeight() > 1){ StretchXbr(scaleToFilter); scaleToFilter.Stretch(where); } else { StretchXbr(where); } break; } } } }
void BaseMesh::CreateBox(float w, float h, float d, int refinement) { Allocate(8, 12); MeshVertex Temp(Vec3f::Origin, Vec3f::Origin, RGBColor::White, Vec2f::Origin); int i,vc=VertexCount(),ic=IndexCount(); MeshVertex *V = Vertices(); DWORD *I = Indices(); for(i=0;i<8;i++) { Temp.Pos = Vec3f(CubeVData[i][0],CubeVData[i][1],CubeVData[i][2]); V[i] = Temp; ///load the vertices } for(i=0;i<12;i++) { I[i*3+0] = CubeIData[i][0]; I[i*3+1] = CubeIData[i][1]; I[i*3+2] = CubeIData[i][2]; //load the triangles } for(i=0;i<refinement;i++) { TwoPatch(); //refine the requested number of times } Stretch(Vec3f(0.5f*w, 0.5f*h, 0.5f*d)); //stretch to the requested dimensions GenerateNormals(); }
void TrueLong::ShiftUp( ulong cnt ) { if( IsZero() ) return; ulong word_cnt = cnt >> 4; Stretch( meenl + word_cnt + 1 ); memset( value + meenl, 0, (word_cnt + 1)*2 ); if( word_cnt ) { memmove( value + word_cnt, value, meenl*2 ); memset( value, 0, word_cnt*2 ); } meenl += word_cnt; uchar bits = uchar(cnt) & 0x0F; // Вот на такое кол-во бит и осталось сдвинуть массив if( !bits ) return; ushort *beg = value + word_cnt, *cur = value + meenl - 1; ushort add = 0; for( ulong* curl; cur >= beg; cur-- ) { curl = (ulong*)cur; (*curl) <<= bits; cur[1] |= add; add = *cur; *cur = 0; } cur[1] |= add; if( value[meenl] ) meenl++; }
void Canvas::StretchNot(const Bitmap &src) { assert(src.IsDefined()); GLLogicOp invert(GL_COPY_INVERTED); Stretch(src); }
void Canvas::Stretch(int dest_x, int dest_y, unsigned dest_width, unsigned dest_height, const GLTexture &texture) { Stretch(dest_x, dest_y, dest_width, dest_height, texture, 0, 0, texture.GetWidth(), texture.GetHeight()); }
void Canvas::Stretch(PixelScalar dest_x, PixelScalar dest_y, UPixelScalar dest_width, UPixelScalar dest_height, const GLTexture &texture) { Stretch(dest_x, dest_y, dest_width, dest_height, texture, 0, 0, texture.GetWidth(), texture.GetHeight()); }
void Stretch(int dest_x, int dest_y, unsigned dest_width, unsigned dest_height, const Canvas &src, int src_x, int src_y, unsigned src_width, unsigned src_height) { Stretch(dest_x, dest_y, dest_width, dest_height, src.buffer, src_x, src_y, src_width, src_height); }
void Canvas::stretch_transparent(const Bitmap &src, Color key) { assert(src.IsDefined()); // XXX Stretch(src); }
void Canvas::Stretch(const Canvas &src, int src_x, int src_y, unsigned src_width, unsigned src_height) { Stretch(0, 0, GetWidth(), GetHeight(), src, src_x, src_y, src_width, src_height); }
void Canvas::Copy(int dest_x, int dest_y, unsigned dest_width, unsigned dest_height, const Bitmap &src, int src_x, int src_y) { Stretch(dest_x, dest_y, dest_width, dest_height, src, src_x, src_y, dest_width, dest_height); }
void Canvas::Stretch(const Bitmap &src) { assert(src.IsDefined()); const PixelSize size = src.GetSize(); Stretch(src, 0, 0, size.cx, size.cy); }
void Canvas::copy(PixelScalar dest_x, PixelScalar dest_y, UPixelScalar dest_width, UPixelScalar dest_height, const Bitmap &src, PixelScalar src_x, PixelScalar src_y) { Stretch(dest_x, dest_y, dest_width, dest_height, src, src_x, src_y, dest_width, dest_height); }
void StretchNotOr(PixelScalar dest_x, PixelScalar dest_y, UPixelScalar dest_width, UPixelScalar dest_height, const Bitmap &src, PixelScalar src_x, PixelScalar src_y, UPixelScalar src_width, UPixelScalar src_height) { Stretch(dest_x, dest_y, dest_width, dest_height, src, src_x, src_y, src_width, src_height, MERGEPAINT); }
void StretchAnd(PixelScalar dest_x, PixelScalar dest_y, UPixelScalar dest_width, UPixelScalar dest_height, const Bitmap &src, PixelScalar src_x, PixelScalar src_y, UPixelScalar src_width, UPixelScalar src_height) { Stretch(dest_x, dest_y, dest_width, dest_height, src, src_x, src_y, src_width, src_height, SRCAND); }
BOOL CCJDockContext::TrackDockBar() { if (::GetCapture() != NULL) return FALSE; m_pBar->SetCapture(); ASSERT(m_pBar == CWnd::GetCapture()); while (CWnd::GetCapture() == m_pBar) { MSG msg; if (!::GetMessage(&msg, NULL, 0, 0)) { AfxPostQuitMessage(msg.wParam); break; } switch (msg.message) { case WM_LBUTTONUP: if (m_bDragging) EndDragDockBar(); else EndResize(); return TRUE; case WM_MOUSEMOVE: if (m_bDragging) MoveDockBar(msg.pt); else Stretch(msg.pt); break; case WM_KEYUP: if (m_bDragging) OnKey((int)msg.wParam, FALSE); break; case WM_KEYDOWN: if (m_bDragging) OnKey((int)msg.wParam, TRUE); if (msg.wParam == VK_ESCAPE) { CancelLoop(); return FALSE; } break; case WM_RBUTTONDOWN: CancelLoop(); return FALSE; // just dispatch rest of the messages default: DispatchMessage(&msg); break; } } CancelLoop(); return FALSE; }
void Canvas::invert_stretch_transparent(const Bitmap &src, Color key) { assert(src.IsDefined()); // XXX GLLogicOp invert(GL_COPY_INVERTED); Stretch(src); }
void Stretch(PixelScalar dest_x, PixelScalar dest_y, UPixelScalar dest_width, UPixelScalar dest_height, const Canvas &src, PixelScalar src_x, PixelScalar src_y, UPixelScalar src_width, UPixelScalar src_height) { Stretch(dest_x, dest_y, dest_width, dest_height, src.surface, src_x, src_y, src_width, src_height); }
void Canvas::Stretch(int dest_x, int dest_y, unsigned dest_width, unsigned dest_height, const Bitmap &src) { assert(src.IsDefined()); const PixelSize size = src.GetSize(); Stretch(dest_x, dest_y, dest_width, dest_height, src, 0, 0, size.cx, size.cy); }
void Canvas::StretchNotOr(PixelScalar dest_x, PixelScalar dest_y, UPixelScalar dest_width, UPixelScalar dest_height, const Bitmap &src, PixelScalar src_x, PixelScalar src_y, UPixelScalar src_width, UPixelScalar src_height) { GLLogicOp logic_op(GL_OR_INVERTED); Stretch(dest_x, dest_y, dest_width, dest_height, src, src_x, src_y, src_width, src_height); }
void Canvas::StretchNot(const Bitmap &src) { assert(IsDefined()); assert(src.IsDefined()); const PixelSize size = src.GetSize(); Stretch(0, 0, GetWidth(), GetHeight(), src.GetNative(), 0, 0, size.cx, size.cy, NOTSRCCOPY); }
void Canvas::Stretch(int dest_x, int dest_y, unsigned dest_width, unsigned dest_height, const Bitmap &_src) { assert(IsDefined()); assert(_src.IsDefined()); ConstImageBuffer src = _src.GetNative(); Stretch(dest_x, dest_y, dest_width, dest_height, src, 0, 0, src.width, src.height); }
void Stretch(PixelScalar dest_x, PixelScalar dest_y, UPixelScalar dest_width, UPixelScalar dest_height, HDC src, PixelScalar src_x, PixelScalar src_y, UPixelScalar src_width, UPixelScalar src_height) { assert(IsDefined()); assert(src != NULL); Stretch(dest_x, dest_y, dest_width, dest_height, src, src_x, src_y, src_width, src_height, SRCCOPY); }
void D3D9Mesh::CreateTeapot(float radius) { //just call the DirectX function to create the teapot FreeMemory(); LPD3DXMESH teapot; D3DXCreateTeapot(GetD3DDevice(), &teapot, NULL); teapot->CloneMeshFVF(D3DMeshOptions, D3DMeshFVF, GetD3DDevice(), &_Mesh); teapot->Release(); Stretch(radius); SetColor(RGBColor::White); GenerateNormals(); }
void Stretch(PixelScalar dest_x, PixelScalar dest_y, UPixelScalar dest_width, UPixelScalar dest_height, const Canvas &src, PixelScalar src_x, PixelScalar src_y, UPixelScalar src_width, UPixelScalar src_height, DWORD dwRop=SRCCOPY) { assert(IsDefined()); assert(src.IsDefined()); Stretch(dest_x, dest_y, dest_width, dest_height, src.dc, src_x, src_y, src_width, src_height, dwRop); }
void Canvas::Stretch(int dest_x, int dest_y, unsigned dest_width, unsigned dest_height, const Bitmap &src, int src_x, int src_y, unsigned src_width, unsigned src_height) { assert(IsDefined()); assert(src.IsDefined()); Stretch(dest_x, dest_y, dest_width, dest_height, src.GetNative(), src_x, src_y, src_width, src_height); }
void Canvas::ScaleCopy(int dest_x, int dest_y, const Bitmap &src, int src_x, int src_y, unsigned src_width, unsigned src_height) { if (Layout::ScaleEnabled()) Stretch(dest_x, dest_y, Layout::Scale(src_width), Layout::Scale(src_height), src, src_x, src_y, src_width, src_height); else Copy(dest_x, dest_y, src_width, src_height, src, src_x, src_y); }
void Canvas::ScaleCopy(PixelScalar dest_x, PixelScalar dest_y, const Bitmap &src, PixelScalar src_x, PixelScalar src_y, UPixelScalar src_width, UPixelScalar src_height) { if (Layout::ScaleEnabled()) Stretch(dest_x, dest_y, Layout::Scale(src_width), Layout::Scale(src_height), src, src_x, src_y, src_width, src_height); else Copy(dest_x, dest_y, src_width, src_height, src, src_x, src_y); }