equal
deleted
inserted
replaced
252 @see MGraphicsDeviceMap::HorizontalTwipsToPixels() */ |
252 @see MGraphicsDeviceMap::HorizontalTwipsToPixels() */ |
253 { |
253 { |
254 TInt64 twips=aTwips; |
254 TInt64 twips=aTwips; |
255 TSize displaySizeInPixels = DisplaySizeInPixels(); |
255 TSize displaySizeInPixels = DisplaySizeInPixels(); |
256 TSize physicalScreenSizeInTwips = PhysicalScreenSizeInTwips(); |
256 TSize physicalScreenSizeInTwips = PhysicalScreenSizeInTwips(); |
|
257 if (displaySizeInPixels.iWidth <= 0 || |
|
258 physicalScreenSizeInTwips.iWidth <= 0) |
|
259 { |
|
260 return 0; |
|
261 } |
257 twips=(twips*displaySizeInPixels.iWidth+(physicalScreenSizeInTwips.iWidth/2))/physicalScreenSizeInTwips.iWidth; |
262 twips=(twips*displaySizeInPixels.iWidth+(physicalScreenSizeInTwips.iWidth/2))/physicalScreenSizeInTwips.iWidth; |
258 return I64INT(twips); |
263 return I64INT(twips); |
259 } |
264 } |
260 |
265 |
261 EXPORT_C TInt CWsScreenDevice::VerticalTwipsToPixels(TInt aTwips) const |
266 EXPORT_C TInt CWsScreenDevice::VerticalTwipsToPixels(TInt aTwips) const |
265 @return The vertical dimension in pixels. */ |
270 @return The vertical dimension in pixels. */ |
266 { |
271 { |
267 TInt64 twips=aTwips; |
272 TInt64 twips=aTwips; |
268 TSize displaySizeInPixels = DisplaySizeInPixels(); |
273 TSize displaySizeInPixels = DisplaySizeInPixels(); |
269 TSize physicalScreenSizeInTwips = PhysicalScreenSizeInTwips(); |
274 TSize physicalScreenSizeInTwips = PhysicalScreenSizeInTwips(); |
|
275 if (displaySizeInPixels.iHeight <= 0 || |
|
276 physicalScreenSizeInTwips.iHeight <= 0) |
|
277 { |
|
278 return 0; |
|
279 } |
270 twips=(twips*displaySizeInPixels.iHeight+(physicalScreenSizeInTwips.iHeight/2))/physicalScreenSizeInTwips.iHeight; |
280 twips=(twips*displaySizeInPixels.iHeight+(physicalScreenSizeInTwips.iHeight/2))/physicalScreenSizeInTwips.iHeight; |
271 return I64INT(twips); |
281 return I64INT(twips); |
272 } |
282 } |
273 |
283 |
274 EXPORT_C TInt CWsScreenDevice::HorizontalPixelsToTwips(TInt aPixels) const |
284 EXPORT_C TInt CWsScreenDevice::HorizontalPixelsToTwips(TInt aPixels) const |
278 @return The equivalent number of twips. */ |
288 @return The equivalent number of twips. */ |
279 { |
289 { |
280 TInt64 pixels=aPixels; |
290 TInt64 pixels=aPixels; |
281 TSize displaySizeInPixels = DisplaySizeInPixels(); |
291 TSize displaySizeInPixels = DisplaySizeInPixels(); |
282 TSize physicalScreenSizeInTwips = PhysicalScreenSizeInTwips(); |
292 TSize physicalScreenSizeInTwips = PhysicalScreenSizeInTwips(); |
|
293 if (displaySizeInPixels.iWidth <= 0 || |
|
294 physicalScreenSizeInTwips.iWidth <= 0) |
|
295 { |
|
296 return 0; |
|
297 } |
283 pixels=(pixels*physicalScreenSizeInTwips.iWidth+(displaySizeInPixels.iWidth/2))/displaySizeInPixels.iWidth; |
298 pixels=(pixels*physicalScreenSizeInTwips.iWidth+(displaySizeInPixels.iWidth/2))/displaySizeInPixels.iWidth; |
284 return I64INT(pixels); |
299 return I64INT(pixels); |
285 } |
300 } |
286 |
301 |
287 EXPORT_C TInt CWsScreenDevice::VerticalPixelsToTwips(TInt aPixels) const |
302 EXPORT_C TInt CWsScreenDevice::VerticalPixelsToTwips(TInt aPixels) const |
292 @see MGraphicsDeviceMap::VerticalPixelsToTwips() */ |
307 @see MGraphicsDeviceMap::VerticalPixelsToTwips() */ |
293 { |
308 { |
294 TInt64 pixels=aPixels; |
309 TInt64 pixels=aPixels; |
295 TSize displaySizeInPixels = DisplaySizeInPixels(); |
310 TSize displaySizeInPixels = DisplaySizeInPixels(); |
296 TSize physicalScreenSizeInTwips = PhysicalScreenSizeInTwips(); |
311 TSize physicalScreenSizeInTwips = PhysicalScreenSizeInTwips(); |
|
312 if (displaySizeInPixels.iHeight <= 0 || |
|
313 physicalScreenSizeInTwips.iHeight <= 0) |
|
314 { |
|
315 return 0; |
|
316 } |
297 pixels=(pixels*physicalScreenSizeInTwips.iHeight+(displaySizeInPixels.iHeight/2))/displaySizeInPixels.iHeight; |
317 pixels=(pixels*physicalScreenSizeInTwips.iHeight+(displaySizeInPixels.iHeight/2))/displaySizeInPixels.iHeight; |
298 return I64INT(pixels); |
318 return I64INT(pixels); |
299 } |
319 } |
300 |
320 |
301 EXPORT_C void CWsScreenDevice::GetPixel(TRgb &aColor,const TPoint &aPixel) const |
321 EXPORT_C void CWsScreenDevice::GetPixel(TRgb &aColor,const TPoint &aPixel) const |