MCPcopy Create free account
hub / github.com/DentonW/DevIL / LoadBitmapAndScale

Method LoadBitmapAndScale

DevIL/bindings/DotNet/DevIL.NET.cpp:179–267  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

177}
178
179System::Drawing::Bitmap __gc* DevIL::DevIL::LoadBitmapAndScale(System::String __gc* i_szFileName,
180 int i_iWidth, int i_iHeight,
181 DevILScaleFilter i_eFilter,
182 DevILScaleKind i_eKind)
183{
184 if (!s_bInitDone)
185 {
186 ilInit();
187 s_bInitDone = true;
188 }
189 ilGenImages(1, &s_iImageID);
190 ilBindImage(s_iImageID);
191
192 if (0==ilLoadImage(StringAutoMarshal(i_szFileName)))
193 {
194 return NULL;
195 }
196
197 int iW = ilGetInteger(IL_IMAGE_WIDTH);
198 int iH = ilGetInteger(IL_IMAGE_HEIGHT);
199 bool bResize = true;
200
201 switch(i_eKind)
202 {
203 case WIDTH_AND_HEIGHT:
204 iW = i_iWidth;
205 iH = i_iHeight;
206 break;
207 case WIDTH_ONLY:
208 iW = i_iWidth;
209 break;
210 case HEIGHT_ONLY:
211 iH = i_iHeight;
212 break;
213 case KEEPRATIO_USING_WIDTH:
214 iH = int(double(iH) * double(i_iWidth) / double(iW));
215 iW = i_iWidth;
216 break;
217 case KEEPRATIO_USING_HEIGHT:
218 iW = int(double(iW) * double(i_iHeight) / double(iH));
219 iH = i_iHeight;
220 break;
221 case DO_NOT_SCALE:
222 bResize = false;
223 break;
224 default:
225 break;
226 }
227
228 System::Drawing::Bitmap __gc* pBmp = __gc new System::Drawing::Bitmap(iW, iH, System::Drawing::Imaging::PixelFormat::Format32bppArgb);
229
230 System::Drawing::Rectangle rect; rect.X = 0; rect.Y = 0; rect.Width = iW; rect.Height = iH;
231
232 System::Drawing::Imaging::BitmapData __gc* pBd = pBmp->LockBits(rect,
233 System::Drawing::Imaging::ImageLockMode::WriteOnly,
234 System::Drawing::Imaging::PixelFormat::Format32bppArgb);
235
236 void* pScan0 = (void*)(pBd->Scan0);

Callers

nothing calls this directly

Calls 1

StringAutoMarshalClass · 0.85

Tested by

no test coverage detected